diff --git a/xos/synchronizer/Dockerfile.synchronizer b/xos/synchronizer/Dockerfile.synchronizer
new file mode 100644
index 0000000..9de9142
--- /dev/null
+++ b/xos/synchronizer/Dockerfile.synchronizer
@@ -0,0 +1,57 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# xosproject/vtn-synchronizer
+FROM xosproject/xos-synchronizer-base:candidate
+
+COPY . /opt/xos/synchronizers/vtn
+
+COPY __init__.py /opt/xos/services/__init__.py
+
+ENTRYPOINT []
+
+WORKDIR "/opt/xos/synchronizers/vtn"
+
+# Label image
+ARG org_label_schema_schema_version=1.0
+ARG org_label_schema_name=vtn-synchronizer
+ARG org_label_schema_version=unknown
+ARG org_label_schema_vcs_url=unknown
+ARG org_label_schema_vcs_ref=unknown
+ARG org_label_schema_build_date=unknown
+ARG org_opencord_vcs_commit_date=unknown
+ARG org_opencord_component_chameleon_version=unknown
+ARG org_opencord_component_chameleon_vcs_url=unknown
+ARG org_opencord_component_chameleon_vcs_ref=unknown
+ARG org_opencord_component_xos_version=unknown
+ARG org_opencord_component_xos_vcs_url=unknown
+ARG org_opencord_component_xos_vcs_ref=unknown
+
+LABEL org.label-schema.schema-version=$org_label_schema_schema_version \
+      org.label-schema.name=$org_label_schema_name \
+      org.label-schema.version=$org_label_schema_version \
+      org.label-schema.vcs-url=$org_label_schema_vcs_url \
+      org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
+      org.label-schema.build-date=$org_label_schema_build_date \
+      org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date \
+      org.opencord.component.chameleon.version=$org_opencord_component_chameleon_version \
+      org.opencord.component.chameleon.vcs-url=$org_opencord_component_chameleon_vcs_url \
+      org.opencord.component.chameleon.vcs-ref=$org_opencord_component_chameleon_vcs_ref \
+      org.opencord.component.xos.version=$org_opencord_component_xos_version \
+      org.opencord.component.xos.vcs-url=$org_opencord_component_xos_vcs_url \
+      org.opencord.component.xos.vcs-ref=$org_opencord_component_xos_vcs_ref
+
+CMD bash -c "cd /opt/xos/synchronizers/vtn; ./run-from-api.sh"
diff --git a/xos/synchronizer/__init__.py b/xos/synchronizer/__init__.py
new file mode 100644
index 0000000..d4e8062
--- /dev/null
+++ b/xos/synchronizer/__init__.py
@@ -0,0 +1,16 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
diff --git a/xos/synchronizer/model-deps b/xos/synchronizer/model-deps
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/xos/synchronizer/model-deps
@@ -0,0 +1 @@
+{}
diff --git a/xos/synchronizer/run-from-api.sh b/xos/synchronizer/run-from-api.sh
new file mode 100755
index 0000000..70ea7eb
--- /dev/null
+++ b/xos/synchronizer/run-from-api.sh
@@ -0,0 +1,17 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+python vtn-synchronizer.py
diff --git a/xos/synchronizer/steps/sync_onos_netcfg.py b/xos/synchronizer/steps/sync_onos_netcfg.py
new file mode 100644
index 0000000..67dc878
--- /dev/null
+++ b/xos/synchronizer/steps/sync_onos_netcfg.py
@@ -0,0 +1,202 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import os
+import requests
+import socket
+import sys
+import base64
+import json
+from synchronizers.new_base.syncstep import SyncStep
+from synchronizers.new_base.modelaccessor import *
+from xos.logger import Logger, logging
+
+logger = Logger(level=logging.INFO)
+
+class SyncONOSNetcfg(SyncStep):
+    provides=[VTNService]
+    observes=VTNService
+    watches=[ModelLink(Node,via='node'), ModelLink(AddressPool,via='addresspool')]
+    requested_interval=0
+
+    def __init__(self, **args):
+        SyncStep.__init__(self, **args)
+
+    def handle_watched_object(self, o):
+        logger.info("handle_watched_object is invoked for object %s" % (str(o)),extra=o.tologdict())
+        if (type(o) is Node): # For Node add/delete/modify
+            self.call()
+        if (type(o) is AddressPool): # For public gateways
+            self.call()
+
+    def get_node_tag(self, node, tagname):
+        tags = Tag.objects.filter(content_type=model_accessor.get_content_type_id(node),
+                                  object_id=node.id,
+                                  name=tagname)
+        return tags[0].value
+
+    def get_service_instances_who_want_config(self):
+        service_instances = []
+        # attribute is comma-separated list
+        for ta in ServiceInstanceAttribute.objects.filter(name="autogenerate"):
+            if ta.value:
+                for config in ta.value.split(','):
+                    if config == "vtn-network-cfg":
+                        service_instances.append(ta.service_instance)
+        return service_instances
+
+    def save_service_instance_attribute(self, service_instance, name, value):
+        tas = ServiceInstanceAttribute.objects.filter(service_instance_id=service_instance.id, name=name)
+        if tas:
+            ta = tas[0]
+            if ta.value != value:
+                logger.info("updating %s with attribute" % name)
+                ta.value = value
+                ta.save()
+        else:
+            logger.info("saving autogenerated config %s" % name)
+            ta = model_accessor.create_obj(ServiceInstanceAttribute, service_instance=service_instance, name=name, value=value)
+            ta.save()
+
+    # This function currently assumes a single Deployment and Site
+    def get_onos_netcfg(self, vtn):
+        privateGatewayMac = vtn.privateGatewayMac
+        localManagementIp = vtn.localManagementIp
+        ovsdbPort = vtn.ovsdbPort
+        sshPort = vtn.sshPort
+        sshUser = vtn.sshUser
+        sshKeyFile = vtn.sshKeyFile
+        mgmtSubnetBits = vtn.mgmtSubnetBits
+        xosEndpoint = vtn.xosEndpoint
+        xosUser = vtn.xosUser
+        xosPassword = vtn.xosPassword
+
+        controllerPort = vtn.controllerPort
+        if ":" in controllerPort:
+            (c_hostname, c_port) = controllerPort.split(":",1)
+            controllerPort = socket.gethostbyname(c_hostname) + ":" + c_port
+        else:
+            controllerPort = ":" + controllerPort
+
+        data = {
+            "apps" : {
+                "org.opencord.vtn" : {
+                    "cordvtn" : {
+                        "privateGatewayMac" : privateGatewayMac,
+                        "localManagementIp": localManagementIp,
+                        "ovsdbPort": ovsdbPort,
+                        "ssh": {
+                            "sshPort": sshPort,
+                            "sshUser": sshUser,
+                            "sshKeyFile": sshKeyFile
+                        },
+                        "xos": {
+                            "endpoint": xosEndpoint,
+                            "user": xosUser,
+                            "password": xosPassword
+                        },
+                        "publicGateways": [],
+                        "nodes" : [],
+                        "controllers": [controllerPort]
+                    }
+                }
+            }
+        }
+
+        # Generate apps->org.opencord.vtn->cordvtn->openstack
+        controllers = Controller.objects.all()
+        if controllers:
+            controller = controllers[0]
+            keystone_server = controller.auth_url
+            user_name = controller.admin_user
+            tenant_name = controller.admin_tenant
+            password = controller.admin_password
+            openstack = {
+                "endpoint": keystone_server,
+                "tenant": tenant_name,
+                "user": user_name,
+                "password": password
+            }
+            data["apps"]["org.opencord.vtn"]["cordvtn"]["openstack"] = openstack
+
+        # Generate apps->org.opencord.vtn->cordvtn->nodes
+        nodes = Node.objects.all()
+        for node in nodes:
+            try:
+                nodeip = socket.gethostbyname(node.name)
+            except socket.gaierror:
+                logger.warn("unable to resolve hostname %s: node will not be added to config"
+                            % node.name)
+                continue
+
+            try:
+                bridgeId = self.get_node_tag(node, "bridgeId")
+                dataPlaneIntf = self.get_node_tag(node, "dataPlaneIntf")
+                dataPlaneIp = self.get_node_tag(node, "dataPlaneIp")
+            except:
+                logger.error("not adding node %s to the VTN configuration" % node.name)
+                continue
+
+            node_dict = {
+                "hostname": node.name,
+                "hostManagementIp": "%s/%s" % (nodeip, mgmtSubnetBits),
+                "bridgeId": bridgeId,
+                "dataPlaneIntf": dataPlaneIntf,
+                "dataPlaneIp": dataPlaneIp
+            }
+
+            # this one is optional
+            try:
+                node_dict["hostManagementIface"] = self.get_node_tag(node, "hostManagementIface")
+            except IndexError:
+                pass
+
+            data["apps"]["org.opencord.vtn"]["cordvtn"]["nodes"].append(node_dict)
+
+        # Generate apps->org.onosproject.cordvtn->cordvtn->publicGateways
+        # Pull the gateway information from Address Pool objects
+        for ap in AddressPool.objects.all():
+            if (not ap.gateway_ip) or (not ap.gateway_mac):
+                logger.info("Gateway_ip or gateway_mac is blank for addresspool %s. Skipping." % ap)
+                continue
+
+            gateway_dict = {
+                "gatewayIp": ap.gateway_ip,
+                "gatewayMac": ap.gateway_mac
+            }
+            data["apps"]["org.opencord.vtn"]["cordvtn"]["publicGateways"].append(gateway_dict)
+
+        if not AddressPool.objects.all().exists():
+            logger.info("No Address Pools present, not adding publicGateways to config")
+
+        return json.dumps(data, indent=4, sort_keys=True)
+
+    # TODO: Does this step execute every 5 seconds regardless of whether objects have changed?
+    #       If so, what purpose does using watchers serve?
+
+    def call(self, **args):
+        vtn_service = VTNService.objects.all()
+        if not vtn_service:
+            raise Exception("No VTN Service")
+
+        vtn_service = vtn_service[0]
+
+        # Check for autogenerate attribute
+        netcfg = self.get_onos_netcfg(vtn_service)
+
+        service_instances = self.get_service_instances_who_want_config()
+        for service_instance in service_instances:
+            self.save_service_instance_attribute(service_instance, "rest_onos/v1/network/configuration/", netcfg)
diff --git a/xos/synchronizer/steps/sync_vtn_service.py b/xos/synchronizer/steps/sync_vtn_service.py
new file mode 100644
index 0000000..e4d4b4f
--- /dev/null
+++ b/xos/synchronizer/steps/sync_vtn_service.py
@@ -0,0 +1,227 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import os
+import requests
+import socket
+import sys
+import base64
+from synchronizers.vtn.vtnnetport import VTNNetwork, VTNPort
+from synchronizers.new_base.syncstep import SyncStep
+from synchronizers.new_base.modelaccessor import *
+from xos.logger import Logger, logging
+from requests.auth import HTTPBasicAuth
+
+logger = Logger(level=logging.INFO)
+
+# XXX should save and load this
+glo_saved_networks = {}
+glo_saved_ports = {}
+
+class SyncVTNService(SyncStep):
+    provides=[Service]
+    observes=Service
+    requested_interval=0
+
+    def __init__(self, **args):
+        SyncStep.__init__(self, **args)
+
+    def get_vtn_onos_app(self, vtn_service):
+        links = vtn_service.subscribed_links.all()
+        for link in links:
+            # We're looking for an ONOS App. It's the only ServiceInstance that VTN can be implemented on.
+            if link.provider_service_instance.leaf_model_name != "ONOSApp":
+                continue
+
+            # TODO: Rather than checking model name, check for the right interface
+            # NOTE: Deferred until new Tosca engine is in place.
+
+            #if not link.provider_service_interface:
+            #    logger.warning("Link %s does not have a provider_service_interface. Skipping" % link)
+            #    continue
+            #
+            #if link.provider_service_interface.interface_type.name != "onos_app_interface":
+            #    logger.warning("Link %s provider_service_interface type is not equal to onos_app_interface" % link)
+            #    continue
+
+            # cast from ServiceInstance to ONOSApp
+            app = link.provider_service_instance.leaf_model
+            return app
+
+        raise Exception("No ServiceInstanceLink from VTN Service to VTN ONOS App")
+
+    def get_vtn_endpoint(self, vtn_service):
+        """ Get connection info for the ONOS that is hosting the VTN ONOS App.
+
+            returns (hostname, port, auth)
+        """
+        app = self.get_vtn_onos_app(vtn_service)
+        # cast from Service to ONOSService
+        onos = app.owner.leaf_model
+        if not (onos.rest_hostname):
+            raise Exception("onos.rest_hostname is not set")
+        if not (onos.rest_port):
+            raise Exception("onos.rest_port is not set")
+        if not (onos.rest_password):
+            raise Exception("onos.rest_password is not set")
+        if not (onos.rest_username):
+            raise Exception("onos.rest_username is not set")
+        auth = HTTPBasicAuth(onos.rest_username, onos.rest_password)
+        return (onos.rest_hostname, onos.rest_port, auth)
+
+    def get_method(self, auth, url, id):
+        url_with_id = "%s/%s" % (url, id)
+        r = requests.get(url_with_id, auth=auth)
+        if (r.status_code==200):
+            method="PUT"
+            url = url_with_id
+            req_func = requests.put
+            exists=True
+        else:
+            method="POST"
+            req_func = requests.post
+            exists=False
+        return (exists, url, method, req_func)
+
+    def sync_service_networks(self, vtn_service):
+        (onos_hostname, onos_port, onos_auth) = self.get_vtn_endpoint(vtn_service)
+
+        valid_ids = []
+        for network in Network.objects.all():
+            network = VTNNetwork(network)
+
+            if not network.id:
+                continue
+
+            if (network.type=="PRIVATE") and (not network.providerNetworks):
+                logger.info("Skipping network %s because it has no relevant state" % network.id)
+                continue
+
+            valid_ids.append(network.id)
+
+            if (glo_saved_networks.get(network.id, None) != network.to_dict()):
+                (exists, url, method, req_func) = self.get_method(onos_auth, "http://%s:%d/onos/cordvtn/serviceNetworks" % (onos_hostname, onos_port), network.id)
+
+                logger.info("%sing VTN API for network %s" % (method, network.id))
+
+                logger.info("URL: %s" % url)
+
+                # clean the providerNetworks list
+                providerNetworks = [{"id": x["id"], "bidirectional": x["bidirectional"]} for x in network.providerNetworks]
+
+                data = {"ServiceNetwork": {"id": network.id,
+                        "type": network.type,
+                        "providerNetworks": providerNetworks} }
+                logger.info("DATA: %s" % str(data))
+
+                r=req_func(url, json=data, auth=onos_auth )
+                if (r.status_code in [200,201]):
+                    glo_saved_networks[network.id] = network.to_dict()
+                else:
+                    logger.error("Received error from vtn service (%d)" % r.status_code)
+
+
+        for network_id in glo_saved_networks.keys():
+            if network_id not in valid_ids:
+                logger.info("DELETEing VTN API for network %s" % network_id)
+
+                url = "http://%s:%d/onos/cordvtn/serviceNetworks/%s" % (onos_hostname, onos_port, network_id)
+                logger.info("URL: %s" % url)
+
+                r = requests.delete(url, auth=onos_auth )
+                if (r.status_code in [200,204]):
+                    del glo_saved_networks[network_id]
+                else:
+                    logger.error("Received error from vtn service (%d)" % r.status_code)
+
+    def sync_service_ports(self, vtn_service):
+        (onos_hostname, onos_port, onos_auth) = self.get_vtn_endpoint(vtn_service)
+
+        valid_ids = []
+        for port in Port.objects.all():
+            port = VTNPort(port)
+
+            if not port.id:
+                continue
+
+            if (not port.vlan_id) and (not port.floating_address_pairs):
+                logger.info("Skipping port %s because it has no relevant state" % port.id)
+                continue
+
+            valid_ids.append(port.id)
+
+            if (glo_saved_ports.get(port.id, None) != port.to_dict()):
+                (exists, url, method, req_func) = self.get_method(onos_auth, "http://%s:%d/onos/cordvtn/servicePorts" % (onos_hostname, onos_port), port.id)
+
+                logger.info("%sing VTN API for port %s" % (method, port.id))
+
+                logger.info("URL: %s" % url)
+
+                data = {"ServicePort": {"id": port.id,
+                        "vlan_id": port.vlan_id,
+                        "floating_address_pairs": port.floating_address_pairs} }
+                logger.info("DATA: %s" % str(data))
+
+                r=req_func(url, json=data, auth=onos_auth )
+                if (r.status_code in [200,201]):
+                    glo_saved_ports[port.id] = port.to_dict()
+                else:
+                    logger.error("Received error from vtn service (%d)" % r.status_code)
+
+        for port_id in glo_saved_ports.keys():
+            if port_id not in valid_ids:
+                logger.info("DELETEing VTN API for port %s" % port_id)
+
+                url = "http://%s:%d/onos/cordvtn/servicePorts/%s" % (onos_hostname, onos_port, port_id)
+                logger.info("URL: %s" % url)
+
+                r = requests.delete(url, auth=onos_auth )
+                if (r.status_code in [200,204]):
+                    del glo_saved_ports[port_id]
+                else:
+                    logger.error("Received error from vtn service (%d)" % r.status_code)
+
+    def call(self, **args):
+        global glo_saved_networks
+        global glo_saved_ports
+
+        vtn_service = VTNService.objects.all()
+        if not vtn_service:
+            raise Exception("No VTN Service")
+
+        vtn_service = vtn_service[0]
+
+        # TODO: We should check get_vtn_onos_app() and make sure that it has been synced, and that any necessary
+        #       attributes (netcfg, etc) is filled out.
+
+        if (vtn_service.resync):
+            # If the VTN app requested a full resync, clear our saved network
+            # so we will resync everything, then reset the 'resync' flag
+            glo_saved_networks = {}
+            glo_saved_ports = {}
+
+            vtn_service.resync = False
+            vtn_service.save()
+
+        if vtn_service.vtnAPIVersion>=2:
+            # version 2 means use new API
+            logger.info("Using New API")
+            self.sync_service_networks(vtn_service)
+            self.sync_service_ports(vtn_service)
+        else:
+            raise Exception("VTN API Version 1 is no longer supported by VTN Synchronizer")
+
+
diff --git a/xos/synchronizer/vtn-synchronizer.py b/xos/synchronizer/vtn-synchronizer.py
new file mode 100755
index 0000000..b5944a8
--- /dev/null
+++ b/xos/synchronizer/vtn-synchronizer.py
@@ -0,0 +1,35 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+#!/usr/bin/env python
+
+# This imports and runs ../../xos-observer.py
+
+import importlib
+import os
+import sys
+from xosconfig import Config
+
+config_file = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + '/vtn_config.yaml')
+Config.init(config_file, 'synchronizer-config-schema.yaml')
+
+sys.path.append('/opt/xos')
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xos.settings")
+
+mod = importlib.import_module("synchronizers.new_base.xos-synchronizer")
+mod.main()
+
diff --git a/xos/synchronizer/vtn_config.yaml b/xos/synchronizer/vtn_config.yaml
new file mode 100644
index 0000000..5a799de
--- /dev/null
+++ b/xos/synchronizer/vtn_config.yaml
@@ -0,0 +1,23 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+name: vtn-synchronizer
+accessor:
+  username: xosadmin@opencord.org
+  password: "@/opt/xos/services/vtn/credentials/xosadmin@opencord.org"
+dependency_graph: "/opt/xos/synchronizers/vtn/model-deps"
+steps_dir: "/opt/xos/synchronizers/vtn/steps"
+sys_dir: "/opt/xos/synchronizers/vtn/sys"
\ No newline at end of file
diff --git a/xos/synchronizer/vtnnetport.py b/xos/synchronizer/vtnnetport.py
new file mode 100644
index 0000000..eaa037f
--- /dev/null
+++ b/xos/synchronizer/vtnnetport.py
@@ -0,0 +1,299 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+from synchronizers.new_base.modelaccessor import *
+in_synchronizer = True
+
+class VTNNetwork(object):
+    def __init__(self, xos_network=None):
+        self.xos_network = xos_network
+
+    def get_controller_network(self):
+        for cn in self.xos_network.controllernetworks.all():
+            # TODO: find the right one
+            return cn
+        return None
+
+    def get_cn_field(self, fieldname):
+        cn=self.get_controller_network()
+        if not cn:
+            return None
+        return getattr(cn, fieldname)
+
+    @property
+    def id(self):
+        return self.get_cn_field("net_id")
+
+    @property
+    def name(self):
+        return self.xos_network.name
+
+    @property
+    def subnet(self):
+        return self.get_cn_field("subnet")
+
+    @property
+    def gateway(self):
+        return self.get_cn_field("gateway")
+
+    @property
+    def segmentation_id(self):
+        return self.get_cn_field("segmentation_id")
+
+    @property
+    def type(self):
+        return self.xos_network.template.vtn_kind
+
+    @property
+    def providerNetworks(self):
+        slice = self.xos_network.owner
+        service = slice.service
+        if not service:
+            return []
+
+        nets=[]
+        for dep in service.subscribed_dependencies.all():
+            if dep.provider_service:
+                bidirectional = dep.connect_method!="private-unidirectional"
+                for net in dep.provider_service.get_composable_networks():
+                    if not net.controllernetworks.exists():
+                        continue
+
+                    cn = net.controllernetworks.all()[0]
+
+                    if not cn.net_id:
+                        continue
+
+                    nets.append({"id": cn.net_id,
+                                 "name": net.name,
+                                 "bidirectional": bidirectional})
+        return nets
+
+    @property
+    def subscriberNetworks(self):
+        slice = self.xos_network.owner
+        service = slice.service
+        if not service:
+            return []
+
+        nets=[]
+        for dep in service.provided_dependencies.all():
+            if dep.subscriber_service:
+                bidirectional = dep.connect_method!="private-unidirectional"
+                for net in dep.subscriber_service.get_composable_networks():
+                    if not net.controllernetworks.exists():
+                        continue
+
+                    cn = net.controllernetworks.all()[0]
+
+                    if not cn.net_id:
+                        continue
+
+                    nets.append({"id": cn.net_id,
+                                 "name": net.name,
+                                 "bidirectional": bidirectional})
+        return nets
+
+    @property
+    def ownerSliceName(self):
+        if self.xos_network.owner:
+            return self.xos_network.owner.name
+        return None
+
+    @property
+    def ownerServiceName(self):
+        if self.xos_network.owner and self.xos_network.owner.service:
+            return self.xos_network.owner.service.name
+        return None
+
+    def to_dict(self):
+        return {"id": self.id,
+                "name": self.name,
+                "subnet": self.subnet,
+                "gateway": self.gateway,
+                "segmentation_id": self.segmentation_id,
+                "type": self.type,
+                "providerNetworks": self.providerNetworks,
+                "subscriberNetworks": self.subscriberNetworks,
+                "ownerSliceName": self.ownerSliceName,
+                "ownerServiceName": self.ownerServiceName}
+
+    def __eq__(self, other):
+        return self.to_dict() == other.to_dict()
+
+class VTNPort(object):
+    def __init__(self, xos_port=None):
+        self.xos_port = xos_port
+
+    def get_controller_network(self):
+        for cn in self.xos_port.network.controllernetworks.all():
+            # TODO: find the right one
+            return cn
+        return None
+
+    def is_access_network(self):
+        """ Determines whether this port is attached to an access network. Currently we do this by examining the
+            network template's vtn_kind field. See if there is a better way...
+        """
+        return self.xos_port.network.template.vtn_kind in ["VSG", ]
+
+    def get_vm_addresses(self):
+        if not self.is_access_network():
+            # If not an access network, do not apply any addresses
+            return []
+
+        if not self.xos_port.instance:
+            return []
+
+        # See if the Instance has any public address (aka "VrouterTenant) service instances associated with it.
+        # If so, then add each of those to the set of address pairs.
+
+        # TODO: Perhaps this should be implemented as a link instead of a tag...
+
+        tags = Tag.objects.filter(name="vm_public_service_instance", object_id=self.xos_port.instance.id,
+                                            content_type=self.xos_port.instance.self_content_type_id)
+
+        if not tags:
+            # DEPRECATED
+            # Historically, VSG instances are tagged with "vm_vrouter_tenant" instead of "vm_public_service_instance"
+            tags = Tag.objects.filter(name="vm_vrouter_tenant", object_id=self.xos_port.instance.id,
+                                                content_type=self.xos_port.instance.self_content_type_id)
+
+        address_pairs = []
+        for tag in tags:
+            si = ServiceInstance.objects.get(id = int(tag.value))
+
+            # cast from Tenant to descendant class (VRouterTenant, etc)
+            si = si.leaf_model
+
+            if (not hasattr(si, "public_ip")) or (not hasattr(si, "public_mac")):
+                raise Exception("Object %s does not have public_ip and/or public_mac fields" % si)
+            address_pairs.append({"ip_address": si.public_ip,
+                                  "mac_address": si.public_mac})
+
+        return address_pairs
+
+    def get_container_addresses(self):
+        if not self.is_access_network():
+            # If not an access network, do not apply any addresses
+            return []
+
+        if not self.xos_port.instance:
+            return []
+
+        addrs = []
+        for si in ServiceInstance.objects.all():
+            # cast from tenant to its descendant class (VSGTenant, etc)
+            si = si.leaf_model
+
+            if not hasattr(si, "instance_id"):
+                # ignore ServiceInstance that don't have instances
+                continue
+
+            if si.instance_id != self.xos_port.instance.id:
+                # ignore ServiceInstances that don't relate to our instance
+                continue
+
+            # Check to see if there is a link public address (aka VRouterTenant)
+            links = si.subscribed_links.all()
+            for link in links:
+                # cast from ServiceInstance to descendant class (VRouterTenant, etc)
+                pubaddr_si = link.provider_service_instance.leaf_model
+                if hasattr(pubaddr_si, "public_ip") and hasattr(pubaddr_si, "public_mac"):
+                    addrs.append({"ip_address": pubaddr_si.public_ip,
+                                  "mac_address": pubaddr_si.public_mac})
+        return addrs
+
+    @property
+    def vlan_id(self):
+        """ Return the vlan_id associated with this instance. This assumes the instance was tagged with either a
+            vlan_id or s_tag tag.
+        """
+
+        if not self.is_access_network():
+            # If not an access network, do not apply any tags
+            return []
+
+        if not self.xos_port.instance:
+            return None
+
+        tags = Tag.objects.filter(content_type=model_accessor.get_content_type_id(self.xos_port.instance),
+                                  object_id=self.xos_port.instance.id,
+                                  name="vlan_id")
+
+        if not tags:
+            # DEPRECATED
+            # Historically, VSG instances are tagged with "s_tag" instead of "vlan_id"
+            tags = Tag.objects.filter(content_type=model_accessor.get_content_type_id(self.xos_port.instance),
+                                      object_id=self.xos_port.instance.id,
+                                      name="s_tag")
+
+        if not tags:
+            return None
+
+        return tags[0].value
+
+    @property
+    def floating_address_pairs(self):
+        # Floating_address_pairs is the set of WAN addresses that should be
+        # applied to this port.
+
+        # We only want to apply these addresses to an "access" network.
+
+
+        address_pairs = self.get_vm_addresses() + self.get_container_addresses()
+
+        return address_pairs
+
+    @property
+    def id(self):
+        return self.xos_port.port_id
+
+    @property
+    def name(self):
+        return "port-%s" % self.xos_port.id
+
+    @property
+    def network_id(self):
+        cn = self.get_controller_network()
+        if not cn:
+            return None
+        return cn.net_id
+
+    @property
+    def network_name(self):
+        return self.xos_port.network.name
+
+    @property
+    def mac_address(self):
+        return self.xos_port.mac
+
+    @property
+    def ip_address(self):
+        return self.xos_port.ip
+
+    def to_dict(self):
+        return {"id": self.id,
+                "name": self.name,
+                "network_id": self.network_id,
+                "mac_address": self.mac_address,
+                "ip_address": self.ip_address,
+                "floating_address_pairs": self.floating_address_pairs,
+                "vlan_id": self.vlan_id}
+
+    def __eq__(self, other):
+        return self.to_dict() == other.to_dict()
+
