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
new file mode 100644
index 0000000..c7d4a48
--- /dev/null
+++ b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/api/OperationType.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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
new file mode 100644
index 0000000..882d04d
--- /dev/null
+++ b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/api/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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
new file mode 100644
index 0000000..49b69a6
--- /dev/null
+++ b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/EnumConverter.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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.node.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) {
+        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) {
+        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) {
+        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) {
+        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;
+        }
+    }
+
+}
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
new file mode 100644
index 0000000..24518d8
--- /dev/null
+++ b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/LinkConverter.java
@@ -0,0 +1,980 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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.link.ExternalDomain;
+import org.onosproject.tetopology.management.api.link.LinkProtectionType;
+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.UnderlayBackupPath;
+import org.onosproject.tetopology.management.api.link.UnderlayPath;
+import org.onosproject.tetopology.management.api.node.TeNetworkTopologyId;
+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.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.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.te.topology.rev20160708
+               .ietftetopology.networks.augmentednwnetworks.te.templates.linktemplate
+               .telinkattributes.LinkProtectionTypeEnum;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.AugmentedNtLink;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.DefaultAugmentedNtLink;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.DefaultAugmentedNtLink.AugmentedNtLinkBuilder;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.DefaultTe;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.DefaultTe.TeBuilder;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.Config;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+.ietftetopology.networks.network.link.augmentedntlink.te.Config.ConfigBuilder;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.DefaultConfig;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.DefaultState;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.State;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+.ietftetopology.networks.network.link.augmentedntlink.te.State.StateBuilder;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.DefaultTeLinkAttributes;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.TeLinkAttributes;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.TeLinkAttributes
+               .TeLinkAttributesBuilder;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
+               .DefaultExternalDomain;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
+               .DefaultExternalDomain.ExternalDomainBuilder;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes.DefaultTeSrlgs;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes.DefaultUnderlay;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
+               .DefaultUnreservedBandwidth;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes.TeSrlgs
+               .TeSrlgsBuilder;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes.Underlay;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes.Underlay
+               .UnderlayBuilder;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
+               .UnreservedBandwidth;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
+               .UnreservedBandwidth.UnreservedBandwidthBuilder;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
+               .underlay.DefaultUnderlayBackupPath;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.ietftetopology
+               .networks.network.link.augmentedntlink.te.config.telinkattributes.underlay
+               .DefaultUnderlayBackupPath.UnderlayBackupPathBuilder;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
+               .underlay.DefaultUnderlayPrimaryPath;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
+               .underlay.DefaultUnderlayTrailDes.UnderlayTrailDesBuilder;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
+               .underlay.DefaultUnderlayTrailSrc.UnderlayTrailSrcBuilder;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
+               .underlay.UnderlayPrimaryPath;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
+               .underlay.UnderlayPrimaryPath.UnderlayPrimaryPathBuilder;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
+               .underlay.underlayprimarypath.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.TeLinkAccessType;
+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.TeTopologyId;
+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.telinkaccesstype.TeLinkAccessTypeEnum;
+
+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 teLink 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 UnderlayBuilder te2YangConfigUnderlayPrimaryPath(
+            UnderlayBuilder yangBuilder,
+            org.onosproject.tetopology.management.api.link.UnderlayPrimaryPath tePath) {
+        UnderlayPrimaryPathBuilder pathBuilder =
+                                       DefaultUnderlayPrimaryPath.builder();
+        if (tePath.pathElements() != null) {
+            for (PathElement pathElementTe : tePath.pathElements()) {
+                org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
+                   .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
+                   .config.telinkattributes.underlay.underlayprimarypath.PathElement
+                   .PathElementBuilder pathElementYangBuilder = DefaultPathElement.builder();
+                // FIXME: pathElementTe does not have any getter or
+                // setter at the moment --> pathElementYangBuilder =
+                // pathElementYangBuilder.pathElementId(pathElementTe.getPathElementId());
+                pathBuilder = pathBuilder.addToPathElement(pathElementYangBuilder.build());
+            }
+        }
+        pathBuilder = pathBuilder.networkIdRef(NetworkId.fromString(
+                                               tePath.ref().getNetworkId().toString()))
+                                 .teTopologyIdRef(TeTopologyId.fromString(
+                                               tePath.ref().getTopologyId().topologyId()));
+        return yangBuilder.underlayPrimaryPath(pathBuilder.build());
+    }
+
+    private static UnderlayBuilder te2YangConfigUnderlayBackupPaths(
+            UnderlayBuilder yangBuilder,
+            List<org.onosproject.tetopology.management.api.link.UnderlayBackupPath> tePaths) {
+
+        for (UnderlayBackupPath tePath : tePaths) {
+            UnderlayBackupPathBuilder pathBuilder = DefaultUnderlayBackupPath.builder();
+            pathBuilder = pathBuilder.index(tePath.index());
+            pathBuilder = pathBuilder.networkIdRef(NetworkId.fromString(
+                                                        tePath.ref().getNetworkId().toString()))
+                                     .teTopologyIdRef(TeTopologyId.fromString(
+                                                        tePath.ref().getTopologyId().topologyId()));
+            for (PathElement backupPathElementTe : tePath.pathElements()) {
+                org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
+                   .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
+                   .config.telinkattributes.underlay.underlaybackuppath.PathElement
+                   .PathElementBuilder elementBuilder =
+                org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
+                   .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
+                   .config.telinkattributes.underlay.underlaybackuppath.DefaultPathElement.builder();
+                // FIXME: backupPathElementTe does not have any
+                // getter or setter at the moment -->
+                // elementBuilder =
+                // elementBuilder.pathElementId(backupPathElementTe.getPathElementId());
+                pathBuilder = pathBuilder.addToPathElement(elementBuilder.build());
+            }
+            yangBuilder = yangBuilder.addToUnderlayBackupPath(pathBuilder.build());
+        }
+
+        return yangBuilder;
+    }
+
+    /**
+     * TE Link underlay path Config object conversion from TE Topology subsystem to YANG.
+     *
+     * @param  tePath TE underlay path object
+     * @return Link underlay path Config YANG object
+     */
+    private static Underlay teSubsystem2YangConfigUnderlayPath(UnderlayPath tePath) {
+        checkNotNull(tePath, E_NULL_TELINK_UNDERLAY_PATH);
+        UnderlayBuilder builder =
+                DefaultUnderlay.builder().underlayProtectionType(tePath.protectionType());
+
+        if (tePath.primaryPath() != null) {
+            builder = te2YangConfigUnderlayPrimaryPath(builder, tePath.primaryPath());
+        }
+        if (tePath.trailSrc() != null) {
+            builder = builder.underlayTrailSrc(
+                                  new UnderlayTrailSrcBuilder()
+                                          .networkRef(NetworkId.fromString(
+                                                  tePath.trailSrc().networkId().toString()))
+                                          .nodeRef(NodeId.fromString(
+                                                  tePath.trailSrc().nodeId().toString()))
+                                          .tpRef(TpId.fromString(
+                                                  tePath.trailSrc().tpId().toString()))
+                                          .build());
+        }
+        if (tePath.trailDes() != null) {
+            builder = builder.underlayTrailDes(
+                                  new UnderlayTrailDesBuilder()
+                                          .networkRef(NetworkId.fromString(
+                                                  tePath.trailDes().networkId().toString()))
+                                          .nodeRef(NodeId.fromString(
+                                                  tePath.trailDes().nodeId().toString()))
+                                          .tpRef(TpId.fromString(
+                                                  tePath.trailDes().tpId().toString()))
+                                          .build());
+        }
+        if (tePath.backupPaths() != null) {
+            builder = te2YangConfigUnderlayBackupPaths(builder, tePath.backupPaths());
+        }
+
+        return builder.build();
+    }
+
+    private static org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
+                      .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
+                      .state.telinkattributes.Underlay.UnderlayBuilder
+            te2YangStateUnderlayPrimaryPath(
+                   org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
+                      .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
+                      .state.telinkattributes.Underlay.UnderlayBuilder yangBuilder,
+                   org.onosproject.tetopology.management.api.link.UnderlayPrimaryPath tePath) {
+        org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+            .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
+            .underlay.UnderlayPrimaryPath.UnderlayPrimaryPathBuilder pathBuilder =
+        org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+            .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
+            .underlay.DefaultUnderlayPrimaryPath.builder();
+        if (tePath.pathElements() != null) {
+            for (PathElement pathElementTe : tePath.pathElements()) {
+                org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
+                   .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
+                   .state.telinkattributes.underlay.underlayprimarypath.PathElement
+                   .PathElementBuilder pathElementYangBuilder =
+                org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
+                   .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
+                   .state.telinkattributes.underlay.underlayprimarypath.DefaultPathElement
+                   .builder();
+                // FIXME: pathElementTe does not have any getter or
+                // setter at the moment --> pathElementYangBuilder =
+                // pathElementYangBuilder.pathElementId(pathElementTe.getPathElementId());
+                pathBuilder = pathBuilder.addToPathElement(pathElementYangBuilder.build());
+            }
+        }
+        pathBuilder = pathBuilder.networkIdRef(NetworkId.fromString(
+                                               tePath.ref().getNetworkId().toString()))
+                                 .teTopologyIdRef(TeTopologyId.fromString(
+                                               tePath.ref().getTopologyId().topologyId()));
+        return yangBuilder.underlayPrimaryPath(pathBuilder.build());
+    }
+
+    private static org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
+                      .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
+                      .state.telinkattributes.Underlay.UnderlayBuilder
+           te2YangStateUnderlayBackupPaths(
+                   org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
+                   .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
+                   .state.telinkattributes.Underlay.UnderlayBuilder yangBuilder,
+            List<org.onosproject.tetopology.management.api.link.UnderlayBackupPath> tePaths) {
+
+        for (UnderlayBackupPath tePath : tePaths) {
+            org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+            .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
+            .underlay.UnderlayBackupPath.UnderlayBackupPathBuilder
+            pathBuilder = org.onosproject.yang.gen.v1.urn.ietf.params.xml
+            .ns.yang.ietf.te.topology.rev20160708.ietftetopology.networks.network.link.augmentedntlink
+            .te.state.telinkattributes.underlay.DefaultUnderlayBackupPath
+                    .builder();
+
+            pathBuilder = pathBuilder.index(tePath.index());
+            pathBuilder = pathBuilder.networkIdRef(NetworkId.fromString(
+                                                        tePath.ref().getNetworkId().toString()))
+                                     .teTopologyIdRef(TeTopologyId.fromString(
+                                                        tePath.ref().getTopologyId().topologyId()));
+            for (PathElement backupPathElementTe : tePath.pathElements()) {
+                org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
+                   .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
+                   .state.telinkattributes.underlay.underlaybackuppath.PathElement
+                   .PathElementBuilder elementBuilder =
+                org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
+                   .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
+                   .state.telinkattributes.underlay.underlaybackuppath.DefaultPathElement.builder();
+                // FIXME: backupPathElementTe does not have any
+                // getter or setter at the moment -->
+                // elementBuilder =
+                // elementBuilder.pathElementId(backupPathElementTe.getPathElementId());
+                pathBuilder = pathBuilder.addToPathElement(elementBuilder.build());
+            }
+            yangBuilder = yangBuilder.addToUnderlayBackupPath(pathBuilder.build());
+        }
+
+        return yangBuilder;
+    }
+
+    /**
+     * TE Link underlay path State object conversion from TE Topology subsystem to YANG.
+     *
+     * @param tePath TE underlay object
+     * @return Link underlay path State YANG object
+     */
+    private static org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
+                       .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te
+                       .state.telinkattributes.Underlay
+                   teSubsystem2YangStateUnderlayPath(UnderlayPath tePath) {
+        checkNotNull(tePath, E_NULL_TELINK_UNDERLAY_PATH);
+
+        org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+            .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
+            .Underlay.UnderlayBuilder builder =
+        org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+            .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
+            .DefaultUnderlay.builder().underlayProtectionType(tePath.protectionType());
+
+        if (tePath.primaryPath() != null) {
+            builder = te2YangStateUnderlayPrimaryPath(builder, tePath.primaryPath());
+
+        }
+        if (tePath.trailSrc() != null) {
+            builder = builder.underlayTrailSrc(
+                          new org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te
+                                  .topology.rev20160708.ietftetopology.networks.network.link
+                                  .augmentedntlink.te.state.telinkattributes.underlay
+                                  .DefaultUnderlayTrailSrc.UnderlayTrailSrcBuilder()
+                              .networkRef(NetworkId.fromString(
+                                              tePath.trailSrc().networkId().toString()))
+                              .nodeRef(NodeId.fromString(
+                                              tePath.trailSrc().nodeId().toString()))
+                              .tpRef(TpId.fromString(
+                                              tePath.trailSrc().tpId().toString()))
+                              .build());
+        }
+        if (tePath.trailDes() != null) {
+            builder = builder.underlayTrailDes(
+                          new org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te
+                                   .topology.rev20160708.ietftetopology.networks.network.link
+                                   .augmentedntlink.te.state.telinkattributes.underlay
+                                   .DefaultUnderlayTrailDes.UnderlayTrailDesBuilder()
+                              .networkRef(NetworkId.fromString(
+                                              tePath.trailDes().networkId().toString()))
+                              .nodeRef(NodeId.fromString(
+                                              tePath.trailDes().nodeId().toString()))
+                              .tpRef(TpId.fromString(
+                                              tePath.trailDes().tpId().toString()))
+                              .build());
+        }
+        if (tePath.backupPaths() != null) {
+            builder = te2YangStateUnderlayBackupPaths(builder, tePath.backupPaths());
+        }
+
+        return builder.build();
+    }
+
+    /**
+     * 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) {
+        checkNotNull(teLink, E_NULL_TELINK_DATA);
+
+        TeLinkAttributesBuilder attrBuilder = DefaultTeLinkAttributes.builder();
+        if (teLink.linkIndex() != null) {
+            attrBuilder = attrBuilder.linkIndex(teLink.linkIndex());
+        }
+        if (teLink.name() != null) {
+            attrBuilder = attrBuilder.name(teLink.name());
+        }
+        if (teLink.adminStatus() != null) {
+            attrBuilder = attrBuilder
+                    .adminStatus(EnumConverter
+                            .teSubsystem2YangAdminStatus(teLink
+                            .adminStatus()));
+        }
+        if (teLink.accessType() != null) {
+            attrBuilder = attrBuilder
+                    .accessType(teSubsystem2YangTeLinkAccess(teLink
+                            .accessType()));
+        }
+        if (teLink.linkProtectionType() != null) {
+            attrBuilder = attrBuilder
+                    .linkProtectionType(teSubsystem2YangLinkProtectionType(teLink
+                            .linkProtectionType()));
+        }
+        if (teLink.maxLinkBandwidth() != null) {
+            attrBuilder = attrBuilder.maxLinkBandwidth(teLink.maxLinkBandwidth());
+        }
+        if (teLink.maxResvLinkBandwidth() != null) {
+            attrBuilder = attrBuilder.maxResvLinkBandwidth(teLink.maxResvLinkBandwidth());
+        }
+        attrBuilder = attrBuilder.teDefaultMetric(teLink.teDefaultMetric());
+        if (teLink.teSrlgs() != null) {
+            TeSrlgsBuilder teSrlgsBuilder = DefaultTeSrlgs.builder();
+            for (Long srlgLongVal : teLink.teSrlgs()) {
+                teSrlgsBuilder = teSrlgsBuilder.addToValue(new Srlg(srlgLongVal));
+            }
+            attrBuilder = attrBuilder.teSrlgs(teSrlgsBuilder.build());
+        }
+        attrBuilder = attrBuilder.isAbstract(teLink.isAbstract());
+        if (teLink.underlayPath() != null) {
+            attrBuilder = attrBuilder.underlay(
+                              teSubsystem2YangConfigUnderlayPath(teLink.underlayPath()));
+        }
+        if (teLink.externalDomain() != null) {
+            ExternalDomainBuilder edBuilder =
+                    DefaultExternalDomain.builder()
+                                         .plugId(teLink.externalDomain().plugId())
+                                         .remoteTeLinkTpId(TeTpId.fromString(
+                                                  teLink.externalDomain().remoteTeLinkTpId().toString()))
+                                         .remoteTeNodeId(TeNodeId.fromString(
+                                                  teLink.externalDomain().remoteTeNodeId().toString()));
+            attrBuilder = attrBuilder.externalDomain(edBuilder.build());
+        }
+
+        if (teLink.unreservedBandwidths() != null) {
+            for (org.onosproject.tetopology.management.api.link.UnreservedBandwidth unResBwTe :
+                        teLink.unreservedBandwidths()) {
+                UnreservedBandwidthBuilder urBuilder =
+                        DefaultUnreservedBandwidth.builder()
+                                                  .bandwidth(unResBwTe.bandwidth())
+                                                  .priority(unResBwTe.priority());
+                attrBuilder = attrBuilder.addToUnreservedBandwidth(urBuilder.build());
+            }
+        }
+
+        ConfigBuilder yangConfigBuilder = DefaultConfig.builder()
+                                                       .teLinkAttributes(attrBuilder.build());
+        return yangConfigBuilder.build();
+    }
+
+    private static LinkProtectionTypeEnum
+                        teSubsystem2YangLinkProtectionType(LinkProtectionType 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 YANGAUTOPREFIX1_FOR_1:
+            return LinkProtectionTypeEnum.YANGAUTOPREFIX1_FOR_1;
+        case YANGAUTOPREFIX1_PLUS_1:
+            return LinkProtectionTypeEnum.YANGAUTOPREFIX1_PLUS_1;
+        default:
+            return null;
+        }
+    }
+
+    private static TeLinkAccessType teSubsystem2YangTeLinkAccess(
+                       org.onosproject.tetopology.management.api.link.TeLinkAccessType accessType) {
+        switch (accessType) {
+        case MULTI_ACCESS:
+            return TeLinkAccessType.of(TeLinkAccessTypeEnum.MULTI_ACCESS);
+        case POINT_TO_POINT:
+            return TeLinkAccessType.of(TeLinkAccessTypeEnum.POINT_TO_POINT);
+        default:
+            return null;
+        }
+    }
+
+    /**
+     * TE Link State object conversion from TE Topology subsystem to YANG.
+     *
+     * @param teLink TE link object
+     * @return TE Link State YANG object
+     */
+    private static State teLink2YangState(TeLink teLink) {
+        org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+            .ietftetopology.networks.network.link.augmentedntlink.te.state.TeLinkAttributes
+            .TeLinkAttributesBuilder attrBuilder =
+        org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+            .ietftetopology.networks.network.link.augmentedntlink.te.state.DefaultTeLinkAttributes
+            .builder()
+            .teDefaultMetric(teLink.teDefaultMetric())
+            .isAbstract(teLink.isAbstract());
+        if (teLink.linkIndex() != null) {
+            attrBuilder = attrBuilder.linkIndex(teLink.linkIndex());
+        }
+        if (teLink.name() != null) {
+            attrBuilder = attrBuilder.name(teLink.name());
+        }
+        if (teLink.adminStatus() != null) {
+            attrBuilder = attrBuilder
+                    .adminStatus(EnumConverter
+                            .teSubsystem2YangAdminStatus(teLink
+                            .adminStatus()));
+        }
+        if (teLink.accessType() != null) {
+            attrBuilder = attrBuilder
+                    .accessType(teSubsystem2YangTeLinkAccess(teLink
+                            .accessType()));
+        }
+        if (teLink.linkProtectionType() != null) {
+            attrBuilder = attrBuilder
+                    .linkProtectionType(teSubsystem2YangStateLinkProtectionType(teLink
+                            .linkProtectionType()));
+        }
+        if (teLink.maxLinkBandwidth() != null) {
+            attrBuilder = attrBuilder.maxLinkBandwidth(teLink.maxLinkBandwidth());
+        }
+        if (teLink.maxResvLinkBandwidth() != null) {
+            attrBuilder = attrBuilder.maxResvLinkBandwidth(teLink.maxResvLinkBandwidth());
+        }
+        if (teLink.teSrlgs() != null) {
+            org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+                .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
+                .TeSrlgs.TeSrlgsBuilder srlgsBuilder =
+            org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+                .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
+                .DefaultTeSrlgs.builder();
+            for (Long srlgLongVal : teLink.teSrlgs()) {
+                srlgsBuilder = srlgsBuilder.addToValue(new Srlg(srlgLongVal));
+            }
+            attrBuilder = attrBuilder.teSrlgs(srlgsBuilder.build());
+        }
+        if (teLink.underlayPath() != null) {
+            attrBuilder = attrBuilder.underlay(teSubsystem2YangStateUnderlayPath(teLink.underlayPath()));
+        }
+        if (teLink.externalDomain() != null) {
+            org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+                    .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
+                    .ExternalDomain.ExternalDomainBuilder edBuilder =
+            org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+                    .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
+                    .DefaultExternalDomain.builder()
+                                          .plugId(teLink.externalDomain().plugId())
+                                          .remoteTeLinkTpId(TeTpId.fromString(
+                                                  teLink.externalDomain().remoteTeLinkTpId().toString()))
+                                          .remoteTeNodeId(TeNodeId.fromString(
+                                                  teLink.externalDomain().remoteTeNodeId().toString()));
+            attrBuilder = attrBuilder.externalDomain(edBuilder.build());
+        }
+        if (teLink.unreservedBandwidths() != null) {
+            for (org.onosproject.tetopology.management.api.link.UnreservedBandwidth unResBwTe :
+                    teLink.unreservedBandwidths()) {
+                org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+                    .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
+                    .UnreservedBandwidth.UnreservedBandwidthBuilder urBuilder =
+                org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+                    .ietftetopology.networks.network.link.augmentedntlink.te.state.telinkattributes
+                    .DefaultUnreservedBandwidth.builder()
+                                               .bandwidth(unResBwTe.bandwidth())
+                                               .priority(unResBwTe.priority());
+                attrBuilder = attrBuilder.addToUnreservedBandwidth(urBuilder.build());
+            }
+        }
+
+        StateBuilder yangStateBuilder = DefaultState.builder()
+                                                    .teLinkAttributes(attrBuilder.build());
+        if (teLink.opStatus() != null) {
+            yangStateBuilder = yangStateBuilder
+                    .operStatus(EnumConverter
+                            .teSubsystem2YangOperStatus(teLink
+                            .opStatus()));
+        }
+
+        return yangStateBuilder.build();
+    }
+
+    private static org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
+        rev20160708.ietftetopology.networks.network.link.augmentedntlink.te.state.informationsourceentry.
+        LinkProtectionTypeEnum teSubsystem2YangStateLinkProtectionType(LinkProtectionType linkProtectionType) {
+        switch (linkProtectionType) {
+        case ENHANCED:
+            return org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
+                    rev20160708.ietftetopology.networks.network.link.augmentedntlink.te.state.informationsourceentry.
+                    LinkProtectionTypeEnum.ENHANCED;
+        case EXTRA_TRAFFIC:
+            return org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
+                    rev20160708.ietftetopology.networks.network.link.augmentedntlink.te.state.informationsourceentry.
+                    LinkProtectionTypeEnum.EXTRA_TRAFFIC;
+        case SHARED:
+            return org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
+                    rev20160708.ietftetopology.networks.network.link.augmentedntlink.te.state.informationsourceentry.
+                    LinkProtectionTypeEnum.SHARED;
+        case UNPROTECTED:
+            return org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
+                    rev20160708.ietftetopology.networks.network.link.augmentedntlink.te.state.informationsourceentry.
+                    LinkProtectionTypeEnum.UNPROTECTED;
+        case YANGAUTOPREFIX1_FOR_1:
+            return org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
+                    rev20160708.ietftetopology.networks.network.link.augmentedntlink.te.state.informationsourceentry.
+                    LinkProtectionTypeEnum.YANGAUTOPREFIX1_FOR_1;
+        case YANGAUTOPREFIX1_PLUS_1:
+            return org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
+                    rev20160708.ietftetopology.networks.network.link.augmentedntlink.te.state.informationsourceentry.
+                    LinkProtectionTypeEnum.YANGAUTOPREFIX1_PLUS_1;
+        default:
+            return null;
+        }
+    }
+
+    /**
+     * Link object conversion from TE Topology subsystem to YANG.
+     *
+     * @param teLink TE subsystem link object
+     * @return YANG link object
+     */
+    public static Link teSubsystem2YangLink(
+            org.onosproject.tetopology.management.api.link.NetworkLink teLink) {
+        checkNotNull(teLink, E_NULL_TELINK);
+
+        LinkId linkId = LinkId.fromString(teLink.linkId().toString());
+        LinkBuilder builder = DefaultLink.builder().linkId(linkId);
+        if (teLink.getSupportingLinkIds() != null) {
+            List<SupportingLink> slinks = Lists.newArrayList();
+            SupportingLinkBuilder spLinkBuilder = DefaultSupportingLink.builder();
+            for (NetworkLinkKey linkKey : teLink.getSupportingLinkIds()) {
+                slinks.add(spLinkBuilder.networkRef(NetworkId.fromString(
+                                                    linkKey.networkId().toString()))
+                                        .linkRef(LinkId.fromString(
+                                                    linkKey.linkId().toString()))
+                                        .build());
+            }
+            builder = builder.supportingLink(slinks);
+        }
+        if (teLink.getSource() != null) {
+            SourceBuilder sourceBuilder = DefaultSource
+                                              .builder()
+                                              .sourceNode(NodeId.fromString(
+                                                   teLink.getSource().nodeId().toString()))
+                                              .sourceTp(TpId.fromString(
+                                                   teLink.getSource().tpId().toString()));
+            builder = builder.source(sourceBuilder.build());
+        }
+        if (teLink.getDestination() != null) {
+            DestinationBuilder destBuilder = DefaultDestination
+                                                 .builder()
+                                                 .destNode(NodeId.fromString(
+                                                      teLink.getDestination().nodeId().toString()))
+                                                 .destTp(TpId.fromString(
+                                                      teLink.getDestination().tpId().toString()));
+            builder = builder.destination(destBuilder.build());
+        }
+
+        if (teLink.getTe() != null) {
+            TeLink teData = teLink.getTe();
+            TeBuilder yangTeBuilder = DefaultTe.builder()
+                                               .config(teLink2YangConfig(teData))
+                                               .state(teLink2YangState(teData));
+            AugmentedNtLinkBuilder linkAugmentBuilder =
+                    DefaultAugmentedNtLink.builder()
+                                          .te(yangTeBuilder.build());
+            builder.addYangAugmentedInfo(linkAugmentBuilder.build(), AugmentedNtLink.class);
+        }
+
+        return builder.build();
+    }
+
+    private static org.onosproject.tetopology.management.api.link.UnderlayPath
+           yang2TeSubsystemUnderlayPrimaryPath(
+                            org.onosproject.tetopology.management.api.link.UnderlayPath teUnderlay,
+                            UnderlayPrimaryPath yangpath) {
+        org.onosproject.tetopology.management.api.link.UnderlayPrimaryPath teUnderlayPrimaryPath =
+                new org.onosproject.tetopology.management.api.link.UnderlayPrimaryPath();
+        teUnderlayPrimaryPath.setRef(new TeNetworkTopologyId(KeyId.keyId(
+                                             yangpath.networkIdRef().toString()),
+                                     new org.onosproject.tetopology.management.api.TeTopologyId(
+                                             yangpath.providerIdRef().uint32(),
+                                             yangpath.clientIdRef().uint32(),
+                                             yangpath.teTopologyIdRef().toString())));
+
+        List<PathElement> pathElementList = Lists.newArrayList();
+        for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+                .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
+                .underlay.underlayprimarypath.PathElement pathElementConfigYang :
+                    yangpath.pathElement()) {
+            //PathElement tePathElement = new PathElement();
+            // FIXME: tePathElement does not have any getter
+            // or setter at the moment -->
+            // tePathElement.set...
+            // TODO: construct the tePathElement object
+            // properly using pathElementConfigYang
+            //pathElementList.add(tePathElement);
+        }
+        teUnderlayPrimaryPath.setPathElement(pathElementList);
+        teUnderlay.setPrimaryPath(teUnderlayPrimaryPath);
+
+        return teUnderlay;
+    }
+
+    private static org.onosproject.tetopology.management.api.link.UnderlayPath
+            yang2TeSubsystemUnderlayBackupPaths(
+                     org.onosproject.tetopology.management.api.link.UnderlayPath teUnderlay,
+                     List<org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te
+                             .topology.rev20160708.ietftetopology.networks.network.link
+                             .augmentedntlink.te.config.telinkattributes.underlay
+                             .UnderlayBackupPath> yangpaths) {
+        List<UnderlayBackupPath> underlayBackupPathsList = Lists.newArrayList();
+        for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+                .ietftetopology.networks.network.link.augmentedntlink.te.config.telinkattributes
+                    .underlay.UnderlayBackupPath yangConfig : yangpaths) {
+            UnderlayBackupPath ubp = new UnderlayBackupPath();
+            ubp.setIndex(yangConfig.index());
+            ubp.setRef(new TeNetworkTopologyId(KeyId.keyId(yangConfig.networkIdRef().toString()),
+                                               new org.onosproject.tetopology.management.api.TeTopologyId(
+                                                       yangConfig.providerIdRef().uint32(),
+                                                       yangConfig.clientIdRef().uint32(),
+                                                       yangConfig.teTopologyIdRef().toString()
+                                              )));
+            List<PathElement> backupPathElementList = Lists.newArrayList();
+            for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
+                    .rev20160708.ietftetopology.networks.network.link.augmentedntlink.te.config
+                    .telinkattributes.underlay.underlaybackuppath.PathElement
+                        pathElementBackupYang : yangConfig.pathElement()) {
+                //PathElement tePathElementBackup = new PathElement();
+                // FIXME: tePathElement does not have any
+                // getter or setter at the moment -->
+                // tePathElement.set...
+                // TODO: construct the tePathElement object
+                // properly using pathElementBackupYang
+                //backupPathElementList.add(tePathElementBackup);
+            }
+            ubp.setPathElement(backupPathElementList);
+        }
+        teUnderlay.setBackupPath(underlayBackupPathsList);
+
+        return teUnderlay;
+    }
+
+    /**
+     * 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) {
+        checkNotNull(yangLinkAtrr, E_NULL_YANG_TELINK_CONFIG);
+
+        org.onosproject.tetopology.management.api.link.UnderlayPath teUnderlay =
+                new org.onosproject.tetopology.management.api.link.UnderlayPath();
+
+        teUnderlay.setProtectionType(yangLinkAtrr.underlay().underlayProtectionType());
+
+        if (yangLinkAtrr.underlay().underlayPrimaryPath() != null) {
+            teUnderlay = yang2TeSubsystemUnderlayPrimaryPath(teUnderlay,
+                                    yangLinkAtrr.underlay().underlayPrimaryPath());
+        }
+
+        if (yangLinkAtrr.underlay().underlayBackupPath() != null) {
+            teUnderlay = yang2TeSubsystemUnderlayBackupPaths(teUnderlay,
+                    yangLinkAtrr.underlay().underlayBackupPath());
+        }
+
+        if (yangLinkAtrr.underlay().underlayTrailSrc() != null) {
+            teUnderlay.setTrailSrc(new TerminationPointKey(
+                                            KeyId.keyId(yangLinkAtrr.underlay().underlayTrailSrc()
+                                                            .networkRef().uri().toString()),
+                                            KeyId.keyId(yangLinkAtrr.underlay().underlayTrailSrc()
+                                                            .nodeRef().uri().toString()),
+                                            KeyId.keyId(yangLinkAtrr.underlay().underlayTrailSrc()
+                                                            .tpRef().uri().toString())));
+        }
+
+        if (yangLinkAtrr.underlay().underlayTrailDes() != null) {
+            teUnderlay.setTrailDes(new TerminationPointKey(
+                                            KeyId.keyId(yangLinkAtrr.underlay().underlayTrailDes()
+                                                            .networkRef().uri().toString()),
+                                            KeyId.keyId(yangLinkAtrr.underlay().underlayTrailDes()
+                                                            .nodeRef().uri().toString()),
+                                            KeyId.keyId(yangLinkAtrr.underlay().underlayTrailDes()
+                                                            .tpRef().uri().toString())));
+        }
+
+        return teUnderlay;
+    }
+
+    private static TeLink yang2TeLinkAttributes(TeLinkAttributes yangLinkAtrr,
+                                                State opState) {
+        TeLink te = new TeLink(yangLinkAtrr.linkIndex());
+        if (yangLinkAtrr.name() != null) {
+            te.setName(yangLinkAtrr.name());
+        }
+        if (yangLinkAtrr.adminStatus() != null) {
+            te.setAdminStatus(EnumConverter.yang2TeSubsystemAdminStatus(
+                                                yangLinkAtrr.adminStatus()));
+        }
+        if (opState != null && opState.operStatus() != null) {
+            te.setOpStatus(EnumConverter.yang2TeSubsystemOpStatus(
+                                             opState.operStatus()));
+        }
+        if (yangLinkAtrr.accessType() != null) {
+            te.setAccessType(yang2TeSubsystemAccessType(
+                                 yangLinkAtrr.accessType()));
+        }
+        if (yangLinkAtrr.linkProtectionType() != null) {
+            te.setLinkProtectionType(yang2TeSubsystemLinkProtectionType(
+                                         yangLinkAtrr.linkProtectionType()));
+        }
+        if (yangLinkAtrr.maxLinkBandwidth() != null) {
+            te.setMaxLinkBandwidth(yangLinkAtrr.maxLinkBandwidth());
+        }
+        if (yangLinkAtrr.maxResvLinkBandwidth() != null) {
+            te.setMaxResvLinkBandwidth(yangLinkAtrr.maxResvLinkBandwidth());
+        }
+        te.setTeDefaultMetric(yangLinkAtrr.teDefaultMetric());
+        te.setIsAbstract(yangLinkAtrr.isAbstract());
+        if (yangLinkAtrr.teSrlgs() != null) {
+            List<Long> srlgs = Lists.newArrayList();
+            for (Srlg srlgConfigYang : yangLinkAtrr.teSrlgs().value()) {
+                srlgs.add(srlgConfigYang.uint32());
+            }
+            te.setTeSrlgs(srlgs);
+        }
+        if (yangLinkAtrr.externalDomain() != null) {
+            te.setExternalDomain(new ExternalDomain(
+                    KeyId.keyId(yangLinkAtrr.externalDomain()
+                                    .remoteTeNodeId().toString()),
+                    KeyId.keyId(yangLinkAtrr.externalDomain()
+                                    .remoteTeLinkTpId().toString()),
+                    yangLinkAtrr.externalDomain().plugId()));
+        }
+        if (yangLinkAtrr.underlay() != null) {
+            te.setUnderlayPath(yang2TeSubsystemUnderlayPath(yangLinkAtrr));
+        }
+        if (yangLinkAtrr.unreservedBandwidth() != null) {
+            List<org.onosproject.tetopology.management.api.link.UnreservedBandwidth>
+                    unreservedBandwidths = Lists.newArrayList();
+            for (UnreservedBandwidth urBwYang : yangLinkAtrr.unreservedBandwidth()) {
+                org.onosproject.tetopology.management.api.link.UnreservedBandwidth unResBw =
+                        new org.onosproject.tetopology.management.api.link.UnreservedBandwidth(
+                                urBwYang.priority(),
+                                urBwYang.bandwidth());
+                unreservedBandwidths.add(unResBw);
+            }
+            te.setUnreservedBandwidths(unreservedBandwidths);
+        }
+        return te;
+    }
+
+    private static LinkProtectionType
+        yang2TeSubsystemLinkProtectionType(LinkProtectionTypeEnum linkProtectionType) {
+        switch (linkProtectionType) {
+        case ENHANCED:
+            return LinkProtectionType.ENHANCED;
+        case EXTRA_TRAFFIC:
+            return LinkProtectionType.EXTRA_TRAFFIC;
+        case SHARED:
+            return LinkProtectionType.SHARED;
+        case UNPROTECTED:
+            return LinkProtectionType.UNPROTECTED;
+        case YANGAUTOPREFIX1_FOR_1:
+            return LinkProtectionType.YANGAUTOPREFIX1_FOR_1;
+        case YANGAUTOPREFIX1_PLUS_1:
+            return LinkProtectionType.YANGAUTOPREFIX1_PLUS_1;
+        default:
+            return null;
+        }
+    }
+
+    private static org.onosproject.tetopology.management.api.link.TeLinkAccessType
+        yang2TeSubsystemAccessType(TeLinkAccessType accessType) {
+        switch (accessType.enumeration()) {
+        case MULTI_ACCESS:
+            return org.onosproject.tetopology.management.api.link.TeLinkAccessType.MULTI_ACCESS;
+        case POINT_TO_POINT:
+            return org.onosproject.tetopology.management.api.link.TeLinkAccessType.POINT_TO_POINT;
+        default:
+            return null;
+        }
+    }
+
+    /**
+     * Link object conversion from YANG to TE Topology subsystem.
+     *
+     * @param yangLink YANG link object
+     * @param networkId YANG networkId object
+     * @return TE subsystem link object
+     */
+    public static org.onosproject.tetopology.management.api.link.NetworkLink
+            yang2TeSubsystemLink(Link yangLink, NetworkId networkId) {
+        checkNotNull(yangLink, E_NULL_YANG_TELINK);
+
+        org.onosproject.tetopology.management.api.link.DefaultNetworkLink link =
+                new org.onosproject.tetopology.management.api.link.DefaultNetworkLink(
+                        KeyId.keyId(yangLink.linkId().uri().toString()));
+
+        if (yangLink.supportingLink() != null) {
+            List<NetworkLinkKey> 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);
+            }
+            link.setSupportingLinkIds(spLinkIds);
+        }
+
+        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()));
+            link.setSource(source);
+        }
+
+        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()));
+            link.setDestination(destination);
+        }
+
+        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) {
+                    TeLink te = yang2TeLinkAttributes(yangLinkAtrr, yangLinkAugment.te().state());
+                    link.setTe(te);
+                }
+            }
+        }
+        return link;
+    }
+
+}
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
new file mode 100644
index 0000000..f529d6a
--- /dev/null
+++ b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/NetworkConverter.java
@@ -0,0 +1,532 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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 java.util.List;
+
+import org.onosproject.tetopology.management.api.KeyId;
+import org.onosproject.tetopology.management.api.link.NetworkLink;
+import org.onosproject.tetopology.management.api.node.NetworkNode;
+import org.onosproject.teyang.api.OperationType;
+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.DefaultNetworks.OnosYangNodeOperationType;
+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.rev20160708
+        .ietftetopology.networks.network.AugmentedNwNetwork;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+        .ietftetopology.networks.network.DefaultAugmentedNwNetwork;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+        .ietftetopology.networks.network.augmentednwnetwork.DefaultTe;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+        .ietftetopology.networks.network.augmentednwnetwork.Te;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+        .ietftetopology.networks.network.networktypes.AugmentedNwNetworkTypes;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+        .ietftetopology.networks.network.networktypes.DefaultAugmentedNwNetworkTypes;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+        .ietftetopology.networks.network.networktypes.augmentednwnetworktypes.DefaultTeTopology;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+        .ietftetopology.networks.network.networktypes.augmentednwnetworktypes.TeTopology;
+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.TeTopologyId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Lists;
+
+
+/**
+ * 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 OnosYangNodeOperationType toNetworksOperationType(OperationType operation) {
+        switch (operation) {
+        case CREATE:
+            return OnosYangNodeOperationType.CREATE;
+
+        case DELETE:
+            return OnosYangNodeOperationType.DELETE;
+
+        case REMOVE:
+            return OnosYangNodeOperationType.REMOVE;
+
+        case MERGE:
+            return OnosYangNodeOperationType.MERGE;
+
+        case REPLACE:
+            return OnosYangNodeOperationType.REPLACE;
+
+        default:
+            return OnosYangNodeOperationType.NONE;
+        }
+    }
+
+    /**
+     * Networks object conversion from TE Topology subsystem to YANG.
+     *
+     * @param teSubsystem TE Topology subsystem networks object
+     * @param operation operation type
+     * @return Networks YANG object
+     */
+    public static Networks teSubsystem2YangNetworks(
+            org.onosproject.tetopology.management.api.Networks teSubsystem,
+            OperationType operation) {
+        checkNotNull(teSubsystem, E_NULL_TE_NETWORKS);
+        checkNotNull(teSubsystem.networks(), E_NULL_TE_NETWORK_LIST);
+        Networks.NetworksBuilder builder =
+                DefaultNetworks.builder().onosYangNodeOperationType(toNetworksOperationType(operation));
+        List<Network> networks = Lists.newArrayList();
+        for (org.onosproject.tetopology.management.api.Network teNetwork : teSubsystem.networks()) {
+            networks.add(teSubsystem2YangNetwork(teNetwork, operation));
+        }
+        builder.network(networks);
+        return builder.build();
+    }
+
+    private static DefaultNetworksState.OnosYangNodeOperationType
+                           toNetworksStateOperationType(OperationType operation) {
+        switch (operation) {
+        case CREATE:
+            return DefaultNetworksState.OnosYangNodeOperationType.CREATE;
+
+        case DELETE:
+            return DefaultNetworksState.OnosYangNodeOperationType.DELETE;
+
+        case REMOVE:
+            return DefaultNetworksState.OnosYangNodeOperationType.REMOVE;
+
+        case MERGE:
+            return DefaultNetworksState.OnosYangNodeOperationType.MERGE;
+
+        case REPLACE:
+            return DefaultNetworksState.OnosYangNodeOperationType.REPLACE;
+
+        default:
+            return DefaultNetworksState.OnosYangNodeOperationType.NONE;
+        }
+    }
+
+    /**
+     * 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().onosYangNodeOperationType(toNetworksStateOperationType(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
+     * @return teSubsystem TE Topology subsystem networks object
+     */
+    public static org.onosproject.tetopology.management.api.Networks yang2TeSubsystemNetworks(
+            Networks yangNetworks, NetworksState yangNetworkStates) {
+        checkNotNull(yangNetworks, E_NULL_YANG_NETWORKS);
+        checkNotNull(yangNetworks.network(), E_NULL_YANG_NETWORK_LIST);
+        checkNotNull(yangNetworkStates, E_NULL_YANG_NETWORKSSTATE);
+
+        org.onosproject.tetopology.management.api.DefaultNetworks defaultNetworks =
+                new org.onosproject.tetopology.management.api.DefaultNetworks();
+        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);
+            } else {
+                teNetwork = yang2TeSubsystemNetwork(network, stateNetwork);
+            }
+            networks.add(teNetwork);
+        }
+
+        defaultNetworks.setNetworks(networks);
+        return defaultNetworks;
+    }
+
+    private static DefaultNetwork.OnosYangNodeOperationType toNetworkOperationType(OperationType operation) {
+        switch (operation) {
+        case CREATE:
+            return DefaultNetwork.OnosYangNodeOperationType.CREATE;
+
+        case DELETE:
+            return DefaultNetwork.OnosYangNodeOperationType.DELETE;
+
+        case REMOVE:
+            return DefaultNetwork.OnosYangNodeOperationType.REMOVE;
+
+        case MERGE:
+            return DefaultNetwork.OnosYangNodeOperationType.MERGE;
+
+        case REPLACE:
+            return DefaultNetwork.OnosYangNodeOperationType.REPLACE;
+
+        default:
+            return DefaultNetwork.OnosYangNodeOperationType.NONE;
+        }
+    }
+
+    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,
+                                               List<NetworkNode> teNodes) {
+        List<Node> nodeList = Lists.newArrayList();
+        // Add each node
+        for (org.onosproject.tetopology.management.api.node.NetworkNode node : teNodes) {
+            // Convert the te node to a YO.
+            nodeList.add(NodeConverter.teSubsystem2YangNode(node));
+        }
+        return builder.node(nodeList);
+    }
+
+    private static NetworkBuilder te2YangLinks(NetworkBuilder builder,
+                                               List<NetworkLink> teLinks) {
+        List<Link> linkList = Lists.newArrayList();
+        // Add each link
+        for (org.onosproject.tetopology.management.api.link.NetworkLink link : teLinks) {
+            // Convert the te link to a YO
+            linkList.add(LinkConverter.teSubsystem2YangLink(link));
+        }
+        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) {
+        Te.TeBuilder teBuilder = DefaultTe.builder();
+        teBuilder.clientId(new TeGlobalId(teTopologyId.clientId()));
+        teBuilder.providerId(new TeGlobalId(teTopologyId.providerId()));
+        if (teTopologyId.topologyId() !=  null) {
+            teBuilder.teTopologyId(new TeTopologyId(teTopologyId.topologyId()));
+        }
+
+        AugmentedNwNetwork.AugmentedNwNetworkBuilder nwAugment = DefaultAugmentedNwNetwork
+                .builder();
+        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
+     * @return Network YANG object
+     */
+    public static Network teSubsystem2YangNetwork(
+            org.onosproject.tetopology.management.api.Network teSubsystem,
+            OperationType operation) {
+        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()
+                                               .onosYangNodeOperationType(
+                                                       toNetworkOperationType(operation))
+                                               .networkId(networkId);
+
+        // Supporting networks
+        if (teSubsystem.getSupportingNetworkIds() != null) {
+            builder = te2YangSupportingNetwork(builder, teSubsystem.getSupportingNetworkIds());
+        }
+
+        // Nodes
+        if (teSubsystem.getNodes() != null) {
+            builder = te2YangNodes(builder, teSubsystem.getNodes());
+        }
+
+        // Network types
+        builder = te2YangNetworkType(builder, teSubsystem.getTeTopologyId());
+
+        // Add links - link is the augmentation
+        if (teSubsystem.getLinks() != null) {
+            builder = te2YangLinks(builder, teSubsystem.getLinks());
+        }
+
+        // TE Topology IDs
+        if (teSubsystem.getTeTopologyId() != null) {
+            builder = te2YangTopologyIds(builder, teSubsystem.getTeTopologyId());
+        }
+
+        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
+     * @return TE Topology subsystem defaultNetwork object
+     */
+    private static org.onosproject.tetopology.management.api.DefaultNetwork yang2TeDefaultNetwork(
+            Network yangNetwork) {
+        checkNotNull(yangNetwork, E_NULL_YANG_NETWORK);
+        checkNotNull(yangNetwork.networkId(), E_NULL_YANG_NETWORKID);
+        String networkId = yangNetwork.networkId().uri().string();
+        org.onosproject.tetopology.management.api.DefaultNetwork teNetwork =
+                new org.onosproject.tetopology.management.api.DefaultNetwork(KeyId.keyId(networkId));
+
+        // Supporting networks
+        if (yangNetwork.supportingNetwork() != null) {
+            List<KeyId> supportingNetworkIds = Lists.newArrayList();
+            for (SupportingNetwork supportNw : yangNetwork.supportingNetwork()) {
+                supportingNetworkIds.add(
+                        KeyId.keyId(supportNw.networkRef().uri().string()));
+            }
+            teNetwork.setSupportingNetworkIds(supportingNetworkIds);
+        }
+
+        // Nodes
+        if (yangNetwork.node() != null) {
+            List<org.onosproject.tetopology.management.api.node.NetworkNode>
+                teNodes = Lists.newArrayList();
+            for (Node node : yangNetwork.node()) {
+                // Convert the Yang Node to a TE node.
+                teNodes.add(NodeConverter.yang2TeSubsystemNode(node, yangNetwork.networkId()));
+            }
+            teNetwork.setNodes(teNodes);
+        }
+
+        // Links
+        if (yangNetwork.yangAugmentedInfo(AugmentedNdNetwork.class) != null) {
+            AugmentedNdNetwork augmentLink =
+                    (AugmentedNdNetwork) yangNetwork.yangAugmentedInfo(AugmentedNdNetwork.class);
+            List<org.onosproject.tetopology.management.api.link.NetworkLink>
+                teLinks = Lists.newArrayList();
+            for (Link link : augmentLink.link()) {
+                // Convert the Yang Link to a TE link.
+                teLinks.add(LinkConverter.yang2TeSubsystemLink(link, yangNetwork.networkId()));
+            }
+            teNetwork.setLinks(teLinks);
+        }
+
+        // TE Topology Ids
+        if (yangNetwork.yangAugmentedInfo(AugmentedNwNetwork.class) != null) {
+            AugmentedNwNetwork augmentTeIds =
+                    (AugmentedNwNetwork) yangNetwork.yangAugmentedInfo(AugmentedNwNetwork.class);
+            org.onosproject.tetopology.management.api.TeTopologyId teTopologyId =
+                    new org.onosproject.tetopology.management.api.TeTopologyId(
+                            augmentTeIds.te().clientId().uint32(),
+                            augmentTeIds.te().providerId().uint32(),
+                            augmentTeIds.te().teTopologyId().string());
+
+            teNetwork.setTeTopologyId(teTopologyId);
+        }
+
+        return teNetwork;
+    }
+
+    /**
+     * Network object conversion from YANG to TE Topology subsystem.
+     *
+     * @param yangNetwork Network YANG object
+     * @return network TE Topology subsystem networks object
+     */
+    public static org.onosproject.tetopology.management.api.Network yang2TeSubsystemNetwork(Network yangNetwork) {
+       return yang2TeDefaultNetwork(yangNetwork);
+    }
+
+    /**
+     * Network and State object conversion from YANG to TE Topology subsystem.
+     *
+     * @param yangNetwork Network YANG object
+     * @param yangNetworkState NetworkState YANG object
+     * @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) {
+        org.onosproject.tetopology.management.api.DefaultNetwork teNetwork =
+                yang2TeDefaultNetwork(yangNetwork);
+
+        checkNotNull(yangNetworkState, E_NULL_YANG_NETWORKSSTATE_NETWORK);
+        checkNotNull(yangNetworkState.networkRef(), E_NULL_YANG_NETWORKSSTATE_NETWORKREF);
+        String networkref = yangNetworkState.networkRef().uri().string();
+        checkState(teNetwork.networkId().toString().equals(networkref),
+                   E_DIFF_YANG_NETWORKID);
+
+        teNetwork.setServerProvided(yangNetworkState.serverProvided());
+
+        return teNetwork;
+    }
+}
+
+
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
new file mode 100644
index 0000000..0af2b13
--- /dev/null
+++ b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/NodeConverter.java
@@ -0,0 +1,567 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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.InterfaceSwitchingCapability;
+import org.onosproject.tetopology.management.api.node.NetworkNodeKey;
+import org.onosproject.tetopology.management.api.node.TeNetworkTopologyId;
+import org.onosproject.tetopology.management.api.node.TeNode;
+import org.onosproject.tetopology.management.api.node.TerminationCapability;
+import org.onosproject.tetopology.management.api.node.TerminationPoint;
+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.DomainName;
+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.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.TpId;
+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.rev20160708
+               .ietftetopology.networks.network.node.AugmentedNwNode;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.DefaultAugmentedNwNode;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.augmentednwnode.DefaultTe;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.augmentednwnode.DefaultTe.TeBuilder;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.augmentednwnode.Te;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.augmentednwnode.te.Config;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.augmentednwnode.te.DefaultConfig;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.augmentednwnode.te.DefaultState;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.augmentednwnode.te.DefaultTunnelTerminationPoint;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.augmentednwnode.te.State;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.augmentednwnode.te.TunnelTerminationPoint;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.augmentednwnode.te.config.DefaultTeNodeAttributes;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.augmentednwnode.te.config.TeNodeAttributes;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.augmentednwnode.te.config.tenodeattributes.ConnectivityMatrix;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.augmentednwnode.te.config.tenodeattributes
+                       .DefaultConnectivityMatrix;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+              .ietftetopology.networks.network.node.augmentednwnode.te.config.tenodeattributes.DefaultUnderlayTopology;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.augmentednwnode.te.config.tenodeattributes.UnderlayTopology;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.augmentednwnode.te.config.tenodeattributes
+                       .connectivitymatrix.DefaultFrom;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.augmentednwnode.te.config.tenodeattributes
+                       .connectivitymatrix.DefaultTo;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.augmentednwnode.te.tunnelterminationpoint
+                       .config.DefaultTerminationCapability;
+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.TeTopologyId;
+
+import com.google.common.collect.Lists;
+
+/**
+ * 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
+     * @return TE Node Config YANG object
+     */
+    private static Config teNode2YangConfig(TeNode teSubsystemTeNode) {
+        checkNotNull(teSubsystemTeNode, E_NULL_TE_SUBSYSTEM_TE_NODE);
+
+        TeNodeAttributes.TeNodeAttributesBuilder teNodeAttributesConfigBuilder =
+                DefaultTeNodeAttributes.builder()
+                                       .isAbstract(teSubsystemTeNode.isAbstract());
+        if (teSubsystemTeNode.adminStatus() != null) {
+            teNodeAttributesConfigBuilder = teNodeAttributesConfigBuilder
+                    .adminStatus(EnumConverter
+                            .teSubsystem2YangAdminStatus(teSubsystemTeNode
+                            .adminStatus()));
+        }
+
+        if (teSubsystemTeNode.name() != null) {
+            teNodeAttributesConfigBuilder = teNodeAttributesConfigBuilder
+                    .name(DomainName.fromString(teSubsystemTeNode.name()));
+        }
+
+        if (teSubsystemTeNode.underlayTopology() != null) {
+            teNodeAttributesConfigBuilder = teNodeAttributesConfigBuilder
+                    .underlayTopology(teNode2YangUnderlayConfig(teSubsystemTeNode.underlayTopology()));
+        }
+
+        if (teSubsystemTeNode.connectivityMatrices() != null) {
+            ConnectivityMatrix.ConnectivityMatrixBuilder connectivityMatrixConfigBuilder =
+                    DefaultConnectivityMatrix.builder();
+            for (org.onosproject.tetopology.management.api.node.ConnectivityMatrix teCm : teSubsystemTeNode.
+                    connectivityMatrices()) {
+                connectivityMatrixConfigBuilder = connectivityMatrixConfigBuilder
+                        .id(teCm.id())
+                        .isAllowed(teCm.isAllowed())
+                        .from(new DefaultFrom.FromBuilder()
+                                .tpRef(TpId.fromString(teCm.from().tpId()
+                                        .toString()))
+                                .build())
+                        .to(new DefaultTo.ToBuilder()
+                                .tpRef(TpId.fromString(teCm.to().tpId()
+                                        .toString()))
+                                .build());
+                teNodeAttributesConfigBuilder = teNodeAttributesConfigBuilder
+                        .addToConnectivityMatrix(connectivityMatrixConfigBuilder
+                                .build());
+            }
+        }
+
+
+        Config.ConfigBuilder yangConfigBuilder = DefaultConfig.builder();
+        yangConfigBuilder = yangConfigBuilder.teNodeAttributes(teNodeAttributesConfigBuilder.build());
+
+        return yangConfigBuilder.build();
+    }
+
+    private static UnderlayTopology teNode2YangUnderlayConfig(TeNetworkTopologyId underlayTopology) {
+        UnderlayTopology.UnderlayTopologyBuilder underlayConfigBuilder = DefaultUnderlayTopology
+                .builder()
+                .networkIdRef(NetworkId.fromString(underlayTopology.getNetworkId().toString()))
+                .teTopologyIdRef(TeTopologyId
+                        .fromString(underlayTopology
+                                .getTopologyId().topologyId()));
+        return underlayConfigBuilder.build();
+    }
+
+    /**
+     * TE Node State object conversion from TE Topology subsystem to YANG.
+     *
+     * @param teSubsystemTeNode TE node object
+     * @return TE Node State YANG object
+     */
+    private static State teNode2YangState(TeNode teSubsystemTeNode) {
+        checkNotNull(teSubsystemTeNode, E_NULL_TE_SUBSYSTEM_TE_NODE);
+
+        org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.ietftetopology
+                .networks.network.node.augmentednwnode.te.state.TeNodeAttributes
+                        .TeNodeAttributesBuilder teNodeAttributesStateBuilder =
+        org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.ietftetopology
+                .networks.network.node.augmentednwnode.te.state.DefaultTeNodeAttributes.builder()
+                .isAbstract(teSubsystemTeNode.isAbstract());
+
+        if (teSubsystemTeNode.adminStatus() != null) {
+            teNodeAttributesStateBuilder = teNodeAttributesStateBuilder
+                    .adminStatus(EnumConverter
+                            .teSubsystem2YangAdminStatus(teSubsystemTeNode
+                            .adminStatus()));
+        }
+
+        if (teSubsystemTeNode.name() != null) {
+            teNodeAttributesStateBuilder = teNodeAttributesStateBuilder
+                    .name(DomainName.fromString(teSubsystemTeNode.name()));
+        }
+
+        if (teSubsystemTeNode.underlayTopology() != null) {
+            org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.ietftetopology
+                    .networks.network.node.augmentednwnode.te.state.tenodeattributes.UnderlayTopology.
+                            UnderlayTopologyBuilder underlayStateBuilder =
+            org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.ietftetopology
+                    .networks.network.node.augmentednwnode.te.state.tenodeattributes.DefaultUnderlayTopology
+                            .builder();
+            underlayStateBuilder = underlayStateBuilder
+                    .networkIdRef(NetworkId.fromString(teSubsystemTeNode
+                                                       .underlayTopology().getNetworkId().toString()))
+                    .teTopologyIdRef(TeTopologyId.fromString(teSubsystemTeNode
+                                                             .underlayTopology().getTopologyId().topologyId()));
+            teNodeAttributesStateBuilder = teNodeAttributesStateBuilder
+                    .underlayTopology(underlayStateBuilder.build());
+        }
+
+        if (teSubsystemTeNode.connectivityMatrices() != null) {
+            org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708.ietftetopology
+            .networks.network.node.augmentednwnode.te.state.tenodeattributes.ConnectivityMatrix
+            .ConnectivityMatrixBuilder
+            connectivityMatrixStateBuilder = org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf
+            .te.topology.rev20160708.ietftetopology.networks.network.node.augmentednwnode
+            .te.state.tenodeattributes.DefaultConnectivityMatrix
+                    .builder();
+            for (org.onosproject.tetopology.management.api.node.ConnectivityMatrix teCm : teSubsystemTeNode
+                    .connectivityMatrices()) {
+                connectivityMatrixStateBuilder = connectivityMatrixStateBuilder
+                        .id(teCm.id())
+                        .isAllowed(teCm.isAllowed())
+                        .from(new org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
+                                .rev20160708.ietftetopology.networks.network.node.augmentednwnode.te.state
+                                .tenodeattributes.connectivitymatrix.DefaultFrom.FromBuilder()
+                                .tpRef(TpId.fromString(teCm.from().tpId()
+                                        .toString()))
+                                .build())
+                        .to(new org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
+                            .rev20160708.ietftetopology.networks.network.node.augmentednwnode.te.state
+                            .tenodeattributes.connectivitymatrix.DefaultTo.ToBuilder()
+                                .tpRef(TpId.fromString(teCm.to().tpId()
+                                        .toString()))
+                                .build());
+                teNodeAttributesStateBuilder = teNodeAttributesStateBuilder
+                        .addToConnectivityMatrix(connectivityMatrixStateBuilder
+                                .build());
+            }
+        }
+
+        State.StateBuilder yangStateBuilder = DefaultState.builder();
+        yangStateBuilder = yangStateBuilder.teNodeAttributes(teNodeAttributesStateBuilder.build());
+
+        if (teSubsystemTeNode.opStatus() != null) {
+            yangStateBuilder = yangStateBuilder.operStatus(EnumConverter
+                    .teSubsystem2YangOperStatus(teSubsystemTeNode
+                            .opStatus()));
+        }
+
+        return yangStateBuilder.build();
+    }
+
+    /**
+     * TE Node TunnelTerminationPoint object conversion from TE Topology subsystem to YANG.
+     *
+     * @param teTunnelTp TE TunnelTerminationPoint object
+     * @return TunnelTerminationPoint YANG object
+     */
+    private static TunnelTerminationPoint teSubsystem2YangTtp(
+                           org.onosproject.tetopology.management.api.node.TunnelTerminationPoint teTunnelTp) {
+        checkNotNull(teTunnelTp, E_NULL_TE_SUBSYSTEM_TE_TUNNEL_TP);
+
+        TunnelTerminationPoint.TunnelTerminationPointBuilder tunnelTpBuilder =
+                DefaultTunnelTerminationPoint.builder().tunnelTpId(teTunnelTp.getTunnelTpId());
+
+        org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+                .ietftetopology.networks.network.node.augmentednwnode.te.tunnelterminationpoint
+                        .Config.ConfigBuilder ttpConfigBuilder =
+        org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+                .ietftetopology.networks.network.node.augmentednwnode.te.tunnelterminationpoint
+                        .DefaultConfig.builder();
+        org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+                .ietftetopology.networks.network.node.augmentednwnode.te.tunnelterminationpoint
+                        .State.StateBuilder ttpStateBuilder =
+        org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+                .ietftetopology.networks.network.node.augmentednwnode.te.tunnelterminationpoint
+                        .DefaultState.builder();
+
+        if (Long.valueOf(teTunnelTp.getInterLayerLockId()) != null) {
+            ttpConfigBuilder = ttpConfigBuilder.interLayerLockId(teTunnelTp.getInterLayerLockId());
+            ttpStateBuilder  = ttpStateBuilder.interLayerLockId(teTunnelTp.getInterLayerLockId());
+        }
+
+        if (teTunnelTp.getSwitchingCapabilities() != null) {
+            // FIXME: switchingCapabilities is a list in
+            // teSubsystem, but is not a list in yang. how to handle
+            // this?
+            for (InterfaceSwitchingCapability iscTe : teTunnelTp.getSwitchingCapabilities()) {
+                // ttpConfigBuilder =
+                // ttpConfigBuilder.switchingCapability(switchingCapability)
+                // ttpStateBuilder =
+                // ttpStateBuilder.switchingCapability(switchingCapability)
+            }
+        }
+
+        if (teTunnelTp.getTerminationCapabilities() != null) {
+            for (TerminationCapability tcap : teTunnelTp.getTerminationCapabilities()) {
+                org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+                        .ietftetopology.networks.network.node.augmentednwnode.te.tunnelterminationpoint.config
+                                .TerminationCapability.TerminationCapabilityBuilder
+                tcapConfigBuilder = DefaultTerminationCapability.builder();
+                // FIXME: at this moment, tcap does not have any getter or setter.
+                // add the following getLinkTpId possibly other attributes to Core data structure
+                // tcapConfigBuilder =
+                // tcapConfigBuilder.linkTp(TpId.fromString(tcap.getLinkTpId.toString()));
+                ttpConfigBuilder = ttpConfigBuilder.addToTerminationCapability(tcapConfigBuilder.build());
+
+                org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+                        .ietftetopology.networks.network.node.augmentednwnode.te.tunnelterminationpoint.state
+                                .TerminationCapability.TerminationCapabilityBuilder tcapStateBuilder =
+                org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+                        .ietftetopology.networks.network.node.augmentednwnode.te.tunnelterminationpoint.state
+                                .DefaultTerminationCapability.builder();
+                // FIXME: at this moment, tcap does not have any getter or setter.
+                // add the following getLinkTpId possibly other attributes to Core data structure
+                // tcapConfigBuilder =
+                // tcapConfigBuilder.linkTp(TpId.fromString(tcap.getLinkTpId.toString()));
+                ttpStateBuilder = ttpStateBuilder.addToTerminationCapability(tcapStateBuilder.build());
+            }
+        }
+
+        tunnelTpBuilder = tunnelTpBuilder.config(ttpConfigBuilder.build())
+                                         .state(ttpStateBuilder.build());
+
+        return tunnelTpBuilder.build();
+    }
+
+    /**
+     * Node object conversion from TE Topology subsystem to YANG.
+     *
+     * @param teSubsystem TE subsystem node object
+     * @return YANG node object
+     */
+    public static Node teSubsystem2YangNode(org.onosproject.tetopology.management.api.node.NetworkNode teSubsystem) {
+        checkNotNull(teSubsystem, E_NULL_TE_SUBSYSTEM_NODE);
+
+        NodeId nodeId = NodeId.fromString(teSubsystem.nodeId().toString());
+        Node.NodeBuilder builder = DefaultNode.builder().nodeId(nodeId);
+
+        if (teSubsystem.getSupportingNodeIds() != null) {
+            List<SupportingNode> sNodes = Lists.newArrayList();
+            SupportingNode.SupportingNodeBuilder spNodeBuilder = DefaultSupportingNode
+                    .builder();
+            for (NetworkNodeKey nodeKey : teSubsystem.getSupportingNodeIds()) {
+                sNodes.add(spNodeBuilder
+                        .networkRef(NetworkId
+                                .fromString(nodeKey.networkId().toString()))
+                        .nodeRef(NodeId.fromString(nodeKey.nodeId().toString()))
+                        .build());
+            }
+            builder = builder.supportingNode(sNodes);
+        }
+
+        if (teSubsystem.getTerminationPoints() != null) {
+            AugmentedNdNode.AugmentedNdNodeBuilder tpAugmentBuilder = DefaultAugmentedNdNode
+                    .builder();
+            List<TerminationPoint> teSubsystemTeTp = teSubsystem
+                    .getTerminationPoints();
+            for (TerminationPoint teTp : teSubsystemTeTp) {
+                tpAugmentBuilder.addToTerminationPoint(TerminationPointConverter
+                        .teSubsystem2YangTerminationPoint(teTp));
+            }
+            builder.addYangAugmentedInfo(tpAugmentBuilder.build(),
+                                         AugmentedNdNode.class);
+        }
+
+        if (teSubsystem.getTe() != null) {
+            AugmentedNwNode.AugmentedNwNodeBuilder nodeAugmentBuilder = DefaultAugmentedNwNode
+                    .builder();
+
+            TeNode teSubsystemTeNode = teSubsystem.getTe();
+
+            TeBuilder yangTeBuilder = DefaultTe.builder();
+
+            if (teSubsystemTeNode.teNodeId() != null) {
+                yangTeBuilder = yangTeBuilder.teNodeId(TeNodeId
+                        .fromString(teSubsystemTeNode.teNodeId().toString()));
+            }
+
+            // Set configuration data
+            // Set state data
+            yangTeBuilder = yangTeBuilder.config(teNode2YangConfig(teSubsystemTeNode))
+                                         .state(teNode2YangState(teSubsystemTeNode));
+
+            if (teSubsystemTeNode.tunnelTerminationPoints() != null) {
+                for (org.onosproject.tetopology.management.api.node.TunnelTerminationPoint
+                        teTunnelTp : teSubsystemTeNode.tunnelTerminationPoints()) {
+                    yangTeBuilder = yangTeBuilder.addToTunnelTerminationPoint(teSubsystem2YangTtp(teTunnelTp));
+                }
+            }
+
+            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 YANG node object
+     * @param yangNetworkId YANG networkId object
+     * @return TE subsystem node object
+     */
+    public static org.onosproject.tetopology.management.api.node.NetworkNode
+                      yang2TeSubsystemNode(Node yangNode, NetworkId yangNetworkId) {
+        checkNotNull(yangNode, E_NULL_YANG_NODE);
+
+        org.onosproject.tetopology.management.api.node.DefaultNetworkNode node =
+                new org.onosproject.tetopology.management.api.node.DefaultNetworkNode(
+                       KeyId.keyId(yangNode.nodeId().uri().string()));
+
+        if (yangNode.supportingNode() != null) {
+            List<NetworkNodeKey> 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);
+            }
+            node.setSupportingNodeIds(spNodes);
+        }
+
+        if (yangNode.yangAugmentedInfoMap() != null
+                && !yangNode.yangAugmentedInfoMap().isEmpty()) {
+
+            AugmentedNdNode yangTpNodeAugment = (AugmentedNdNode) yangNode
+                    .yangAugmentedInfo(AugmentedNdNode.class);
+            if (yang2TeSubsystemTpNodeAugment(yangTpNodeAugment) != null) {
+                node.setTerminationPoints(yang2TeSubsystemTpNodeAugment(yangTpNodeAugment));
+            }
+
+            AugmentedNwNode yangNodeAugment = (AugmentedNwNode) yangNode
+                    .yangAugmentedInfo(AugmentedNwNode.class);
+            if (yangNodeAugment != null && yangNodeAugment.te() != null && yangNodeAugment.te().teNodeId() != null) {
+                Te yangNodeAugTe = yangNodeAugment.te();
+                TeNode teNode = yang2TeSubsystemNodeAugment(yangNodeAugTe, yangNetworkId, yangNode.nodeId());
+                node.setTe(teNode);
+            }
+        }
+
+        return node;
+    }
+
+    private static TeNode yang2TeSubsystemNodeConnectivityMatrix(TeNode teNode,
+            String networkId, String nodeId, List<ConnectivityMatrix> yangMatrix) {
+        List<org.onosproject.tetopology.management.api.node.ConnectivityMatrix> teCmList =
+                Lists.newArrayList();
+        for (ConnectivityMatrix cmYang : yangMatrix) {
+            Long id = cmYang.id();
+            TerminationPointKey from = new TerminationPointKey(
+                                           KeyId.keyId(networkId),
+                                           KeyId.keyId(nodeId),
+                                           KeyId.keyId(cmYang.from().tpRef().uri().toString()));
+            TerminationPointKey to = new TerminationPointKey(
+                                           KeyId.keyId(networkId),
+                                           KeyId.keyId(nodeId),
+                                           KeyId.keyId(cmYang.to().tpRef().uri().toString()));
+            boolean isAllowed = cmYang.isAllowed();
+            org.onosproject.tetopology.management.api.node.ConnectivityMatrix cmTe =
+                    new org.onosproject.tetopology.management.api.node.ConnectivityMatrix(
+                            id, from, to, isAllowed);
+            teCmList.add(cmTe);
+        }
+        teNode.setConnectivityMatrices(teCmList);
+        return teNode;
+    }
+
+    private static TeNode yang2TeSubsystemNodeUnderlayTopology(TeNode teNode,
+                                                               UnderlayTopology ut) {
+        TeNetworkTopologyId underlayTopology =
+                new TeNetworkTopologyId(KeyId.keyId(ut.networkIdRef().uri().toString()),
+                new org.onosproject.tetopology.management.api.TeTopologyId(
+                            ut.providerIdRef().uint32(),
+                            ut.clientIdRef().uint32(),
+                            ut.teTopologyIdRef().toString()));
+        teNode.setUnderlayTopology(underlayTopology);
+        return teNode;
+    }
+
+    private static TeNode yang2TeSubsystemTtp(TeNode teNode,
+                                              List<TunnelTerminationPoint> ttps) {
+        List<org.onosproject.tetopology.management.api.node.TunnelTerminationPoint> ttpTeList =
+                Lists.newArrayList();
+        for (TunnelTerminationPoint ttpYang : ttps) {
+            org.onosproject.tetopology.management.api.node.TunnelTerminationPoint ttpTe =
+                    new org.onosproject.tetopology.management.api.node.TunnelTerminationPoint(
+                            ttpYang.tunnelTpId());
+            ttpTe.setInterLayerLockId(ttpYang.config().interLayerLockId());
+            // FIXME: go through
+            // ttpYang.config().switchingCapability() and populate
+            // ttpTe.setSwitchingCapabilities(switchingCapabilities);
+            // FIXME: go through
+            // ttpYang.config().terminationCapability() and populate
+            // ttpTe.setTerminationCapability(terminationCapability);
+            ttpTeList.add(ttpTe);
+        }
+        teNode.setTunnelTerminationPoints(ttpTeList);
+
+        return teNode;
+    }
+
+    private static TeNode yang2TeSubsystemNodeAugment(Te yangNodeAugTe,
+            NetworkId yangNetworkId, NodeId yangNodeId) {
+        TeNode teNode = new TeNode(yangNodeAugTe.teNodeId().toString());
+        Config ynodeAugCfg = yangNodeAugTe.config();
+        if (ynodeAugCfg != null) {
+            TeNodeAttributes teNodeAttr = ynodeAugCfg.teNodeAttributes();
+            if (teNodeAttr != null) {
+                teNode.setAbstract(teNodeAttr.isAbstract());
+
+                if (teNodeAttr.adminStatus() != null) {
+                    teNode.setAdminStatus(EnumConverter.yang2TeSubsystemAdminStatus(
+                                                            ynodeAugCfg.teNodeAttributes().adminStatus()));
+                }
+
+                if (yangNodeAugTe.state() != null &&
+                        yangNodeAugTe.state().operStatus() != null) {
+                    teNode.setOpStatus(EnumConverter.yang2TeSubsystemOpStatus(
+                                                         yangNodeAugTe.state().operStatus()));
+                }
+
+                if (teNodeAttr.connectivityMatrix() != null) {
+                    teNode = yang2TeSubsystemNodeConnectivityMatrix(teNode,
+                                                                    yangNetworkId.uri().toString(),
+                                                                    yangNodeId.uri().toString(),
+                                                                    teNodeAttr.connectivityMatrix());
+                }
+
+                if (teNodeAttr.underlayTopology() != null) {
+                    teNode = yang2TeSubsystemNodeUnderlayTopology(teNode,
+                                                                  teNodeAttr.underlayTopology());
+                }
+            }
+        }
+
+        if (yangNodeAugTe.tunnelTerminationPoint() != null) {
+            teNode = yang2TeSubsystemTtp(teNode, yangNodeAugTe.tunnelTerminationPoint());
+        }
+        return teNode;
+    }
+
+    private static List<TerminationPoint> yang2TeSubsystemTpNodeAugment(AugmentedNdNode yangTpNodeAugment) {
+        if (yangTpNodeAugment.terminationPoint() != null) {
+            List<TerminationPoint> teTpList = Lists.newArrayList();
+            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()) {
+                teTpList.add(TerminationPointConverter.yang2teSubsystemTerminationPoint(yangTpnode));
+            }
+            return teTpList;
+        }
+        return null;
+    }
+}
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
new file mode 100644
index 0000000..ec74b9e
--- /dev/null
+++ b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/TerminationPointConverter.java
@@ -0,0 +1,225 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS 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.TeTerminationPoint;
+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.rev20160708
+               .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint.DefaultTe;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint.Te.TeBuilder;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint.te.Config;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint.te.DefaultConfig;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint.te.DefaultState;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint.te.State;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint
+                       .te.config.DefaultInterfaceSwitchingCapability;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint
+                       .te.config.InterfaceSwitchingCapability;
+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.topology.rev20160708
+               .ietftetopology.networks.network.node.terminationpoint.AugmentedNtTerminationPoint;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+               .ietftetopology.networks.network.node.terminationpoint.DefaultAugmentedNtTerminationPoint;
+
+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 object
+     * @return TerminationPoint YANG object
+     */
+    public static TerminationPoint teSubsystem2YangTerminationPoint(
+                                       org.onosproject.tetopology.management.api.node.TerminationPoint teSubsystem) {
+        checkNotNull(teSubsystem, E_NULL_TE_SUBSYSTEM_TP);
+
+        TpId tpId = TpId.fromString(teSubsystem.id().toString());
+        TerminationPoint.TerminationPointBuilder builder =
+                new DefaultTerminationPoint.TerminationPointBuilder().tpId(tpId);
+
+        if (teSubsystem.getSupportingTpIds() != null) {
+            List<SupportingTerminationPoint> tps = Lists.newArrayList();
+            SupportingTerminationPoint.SupportingTerminationPointBuilder
+                    spTpBuilder = DefaultSupportingTerminationPoint.builder();
+            for (TerminationPointKey tpKey : teSubsystem.getSupportingTpIds()) {
+                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.getTe() != null) {
+            AugmentedNtTerminationPoint.AugmentedNtTerminationPointBuilder
+                    tpAugmentBuilder = DefaultAugmentedNtTerminationPoint.builder();
+
+            TeTerminationPoint teSubsystemTe = teSubsystem.getTe();
+            TeBuilder yangTeBuilder = DefaultTe.builder();
+
+            if (teSubsystemTe.teTpId() != null) {
+                yangTeBuilder = yangTeBuilder.teTpId(TeTpId.fromString(teSubsystemTe.teTpId().toString()));
+            }
+
+            Config yConfig = teSubsystem2YangTeAugConfig(teSubsystemTe);
+            yangTeBuilder = yangTeBuilder.config(yConfig);
+
+            State yState = teSubsystem2YangTeAugState(teSubsystemTe);
+            yangTeBuilder = yangTeBuilder.state(yState);
+
+            tpAugmentBuilder = tpAugmentBuilder.te(yangTeBuilder.build());
+            builder.addYangAugmentedInfo(tpAugmentBuilder.build(), AugmentedNtTerminationPoint.class);
+        }
+
+        return builder.build();
+    }
+
+    private static State teSubsystem2YangTeAugState(TeTerminationPoint teSubsystemTe) {
+        State.StateBuilder yangStateBuilder = DefaultState.builder();
+        yangStateBuilder.interLayerLockId(teSubsystemTe.getInterLayerLockId());
+
+        if (teSubsystemTe.interfaceSwitchingCapabilities() != null) {
+            for (org.onosproject.tetopology.management.api.node.InterfaceSwitchingCapability teIsc :
+                    teSubsystemTe.interfaceSwitchingCapabilities()) {
+                org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160708
+                    .ietftetopology.networks.network.node.terminationpoint.augmentedntterminationpoint
+                        .te.state.InterfaceSwitchingCapability.InterfaceSwitchingCapabilityBuilder
+                isc = org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
+                          .rev20160708.ietftetopology.networks.network.node.terminationpoint
+                              .augmentedntterminationpoint.te.state.DefaultInterfaceSwitchingCapability.builder();
+                // FIXME: teIsc at this moment is empty, therefore we cannot
+                // really add its attributes to isc
+                yangStateBuilder.addToInterfaceSwitchingCapability(isc.build());
+            }
+        }
+        return yangStateBuilder.build();
+    }
+
+    private static Config teSubsystem2YangTeAugConfig(TeTerminationPoint teSubsystemTe) {
+        Config.ConfigBuilder yangConfigBuilder = DefaultConfig.builder();
+        yangConfigBuilder = yangConfigBuilder.interLayerLockId(teSubsystemTe.getInterLayerLockId());
+        if (teSubsystemTe.interfaceSwitchingCapabilities() != null) {
+            for (org.onosproject.tetopology.management.api.node.InterfaceSwitchingCapability teIsc :
+                    teSubsystemTe.interfaceSwitchingCapabilities()) {
+                InterfaceSwitchingCapability.InterfaceSwitchingCapabilityBuilder
+                    isc = DefaultInterfaceSwitchingCapability.builder();
+                // FIXME: teIsc at this moment is empty, therefore we cannot
+                // really add its attributes to isc
+                yangConfigBuilder = yangConfigBuilder.addToInterfaceSwitchingCapability(isc.build());
+            }
+        }
+        return yangConfigBuilder.build();
+    }
+
+    /**
+     * TerminationPoint object translation from YANG to TE Topology subsystem.
+     *
+     * @param yangTp TerminationPoint YANG object
+     * @return TerminationPoint TE Topology subsystem termination point object
+     */
+    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 = new org.onosproject.tetopology
+                .management.api.node.DefaultTerminationPoint(KeyId.keyId(yangTp.tpId().uri().string()));
+
+        if (yangTp.supportingTerminationPoint() != null) {
+            List<org.onosproject.tetopology.management.api.node.TerminationPointKey> 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);
+            }
+            tp.setSupportingTpIds(spTps);
+        }
+
+        if (yangTp.yangAugmentedInfoMap() != null && !yangTp.yangAugmentedInfoMap().isEmpty()) {
+            AugmentedNtTerminationPoint yangTpAugment =
+                    (AugmentedNtTerminationPoint) yangTp.yangAugmentedInfo(AugmentedNtTerminationPoint.class);
+            if (yangTpAugment.te() != null && yangTpAugment.te().teTpId() != null) {
+                KeyId teTpId = KeyId.keyId(yangTpAugment.te().teTpId().toString());
+                if (yangTpAugment.te().config() != null) {
+                    long interLayerLockId = yangTpAugment.te().config().interLayerLockId();
+                    List<org.onosproject.tetopology.management.api.node.InterfaceSwitchingCapability>
+                            teIscList = Lists.newArrayList();
+                    // FIXME: the following line is for config. State also has
+                    // similar stuff, but Te Subsystem does not diffrentiate
+                    // between the two
+                    if (yangTpAugment.te().config().interfaceSwitchingCapability() != null) {
+                        for (InterfaceSwitchingCapability iscConfigYang :
+                                yangTpAugment.te().config().interfaceSwitchingCapability()) {
+                            org.onosproject.tetopology.management.api.node.InterfaceSwitchingCapability iscTe =
+                                    new org.onosproject.tetopology.management.api.node.InterfaceSwitchingCapability();
+                            // FIXME: at this moment, iscTe does not have any
+                            // attributes. Therefore, I cannot feed it with
+                            // attributes of iscConfigYang
+                            teIscList.add(iscTe);
+                        }
+                    }
+
+                    TeTerminationPoint teSubsystemTp = new TeTerminationPoint(teTpId,
+                                                                              teIscList,
+                                                                              interLayerLockId);
+                    tp.setTe(teSubsystemTp);
+                }
+            }
+        }
+        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
new file mode 100644
index 0000000..f11dfdc
--- /dev/null
+++ b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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;
