diff --git a/xos/synchronizer/steps/sync_onosapp.py b/xos/synchronizer/steps/sync_onosapp.py
index d421aa1..26bb49b 100644
--- a/xos/synchronizer/steps/sync_onosapp.py
+++ b/xos/synchronizer/steps/sync_onosapp.py
@@ -16,9 +16,6 @@
 from core.models import Service, Slice, Controller, ControllerSlice, ControllerUser, Node, TenantAttribute, Tag
 from services.onos.models import ONOSService, ONOSApp
 from xos.logger import Logger, logging
-from services.vrouter.models import VRouterService
-from services.vtn.models import VTNService
-from services.volt.models import VOLTService, VOLTDevice, AccessDevice
 
 # hpclibrary will be in steps/..
 parentdir = os.path.join(os.path.dirname(__file__),"..")
@@ -119,250 +116,6 @@
                 raise Exception("Controller user object for %s does not exist" % instance.creator)
             return cuser.kuser_id
 
-    def get_node_tag(self, o, node, tagname):
-        tags = Tag.select_by_content_object(node).filter(name=tagname)
-        return tags[0].value
-
-    # Scan attrs for attribute name
-    # If it's not present, save it as a TenantAttribute
-    def attribute_default(self, tenant, attrs, name, default):
-        if name in attrs:
-            value = attrs[name]
-        else:
-            value = default
-            logger.info("saving default value %s for attribute %s" % (value, name))
-            ta = TenantAttribute(tenant=tenant, name=name, value=value)
-            ta.save()
-        return value
-
-    # This function currently assumes a single Deployment and Site
-    def get_vtn_config(self, o, attrs):
-
-        privateGatewayMac = None
-        localManagementIp = None
-        ovsdbPort = None
-        sshPort = None
-        sshUser = None
-        sshKeyFile = None
-        mgmtSubnetBits = None
-        xosEndpoint = None
-        xosUser = None
-        xosPassword = None
-
-        # VTN-specific configuration from the VTN Service
-        vtns = VTNService.get_service_objects().all()
-        if vtns:
-            vtn = vtns[0]
-            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
-
-        # OpenStack endpoints and credentials
-        keystone_server = "http://keystone:5000/v2.0/"
-        user_name = "admin"
-        password = "ADMIN_PASS"
-        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
-
-        data = {
-            "apps" : {
-                "org.opencord.vtn" : {
-                    "cordvtn" : {
-                        "privateGatewayMac" : privateGatewayMac,
-                        "localManagementIp": localManagementIp,
-                        "ovsdbPort": ovsdbPort,
-                        "ssh": {
-                            "sshPort": sshPort,
-                            "sshUser": sshUser,
-                            "sshKeyFile": sshKeyFile
-                        },
-                        "openstack": {
-                            "endpoint": keystone_server,
-                            "tenant": tenant_name,
-                            "user": user_name,
-                            "password": password
-                        },
-                        "xos": {
-                            "endpoint": xosEndpoint,
-                            "user": xosUser,
-                            "password": xosPassword
-                        },
-                        "publicGateways": [],
-                        "nodes" : []
-                    }
-                }
-            }
-        }
-
-        # Generate apps->org.opencord.vtn->cordvtn->nodes
-        nodes = Node.objects.all()
-        for node in nodes:
-            nodeip = socket.gethostbyname(node.name)
-
-            try:
-                bridgeId = self.get_node_tag(o, node, "bridgeId")
-                dataPlaneIntf = self.get_node_tag(o, node, "dataPlaneIntf")
-                dataPlaneIp = self.get_node_tag(o, 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
-            }
-            data["apps"]["org.opencord.vtn"]["cordvtn"]["nodes"].append(node_dict)
-
-        # Generate apps->org.onosproject.cordvtn->cordvtn->publicGateways
-        # Pull the gateway information from vRouter
-        vrouters = VRouterService.get_service_objects().all()
-        if vrouters:
-            for gateway in vrouters[0].get_gateways():
-                gatewayIp = gateway['gateway_ip'].split('/',1)[0]
-                gatewayMac = gateway['gateway_mac']
-                gateway_dict = {
-                    "gatewayIp": gatewayIp,
-                    "gatewayMac": gatewayMac
-                }
-                data["apps"]["org.opencord.vtn"]["cordvtn"]["publicGateways"].append(gateway_dict)
-
-        return json.dumps(data, indent=4, sort_keys=True)
-
-    def get_volt_network_config(self, o, attrs):
-        try:
-            volt = VOLTService.get_service_objects().all()[0]
-        except:
-            return None
-
-        devices = []
-        for voltdev in volt.volt_devices.all():
-            access_devices = []
-            for access in voltdev.access_devices.all():
-                access_device = {
-                    "uplink" : access.uplink,
-                    "vlan" : access.vlan
-                }
-                access_devices.append(access_device)
-
-            if voltdev.access_agent:
-                agent = voltdev.access_agent
-                olts = {}
-                for port_mapping in agent.port_mappings.all():
-                    olts[port_mapping.port] = port_mapping.mac
-                agent_config = {
-                    "olts" : olts,
-                    "mac" : agent.mac
-                }
-
-            device = {
-                voltdev.openflow_id : {
-                    "accessDevice" : access_devices,
-                    "accessAgent" : agent_config
-                },
-                "basic" : {
-                    "driver" : voltdev.driver
-                }
-            }
-            devices.append(device)
-
-        data = {
-            "devices" : devices
-        }
-        return json.dumps(data, indent=4, sort_keys=True)
-
-    def get_volt_component_config(self, o, attrs):
-        data = {
-            "org.ciena.onos.ext_notifier.KafkaNotificationBridge":{
-                "rabbit.user": "<rabbit_user>",
-                "rabbit.password": "<rabbit_password>",
-                "rabbit.host": "<rabbit_host>",
-                "publish.kafka": "false",
-                "publish.rabbit": "true",
-                "volt.events.rabbit.topic": "notifications.info",
-                "volt.events.rabbit.exchange": "voltlistener",
-                "volt.events.opaque.info": "{project_id: <keystone_tenant_id>, user_id: <keystone_user_id>}",
-                "publish.volt.events": "true"
-            }
-        }
-        return json.dumps(data, indent=4, sort_keys=True)
-
-    def get_vrouter_network_config(self, o, attrs):
-        # From the onosproject wiki:
-        # https://wiki.onosproject.org/display/ONOS/vRouter
-        data = {
-            "devices" : {
-                "of:00000000000000b1" : {
-                    "basic" : {
-                        "driver" : "softrouter"
-                    }
-                }
-            },
-            "ports" : {
-                "of:00000000000000b1/1" : {
-                    "interfaces" : [
-                        {
-                            "name" : "b1-1",
-                            "ips"  : [ "10.0.1.2/24" ],
-                            "mac"  : "00:00:00:00:00:01"
-                        }
-                    ]
-                },
-                "of:00000000000000b1/2" : {
-                    "interfaces" : [
-                        {
-                            "name" : "b1-2",
-                            "ips"  : [ "10.0.2.2/24" ],
-                            "mac"  : "00:00:00:00:00:01"
-                        }
-                    ]
-                },
-                "of:00000000000000b1/3" : {
-                    "interfaces" : [
-                        {
-                            "name" : "b1-3",
-                            "ips"  : [ "10.0.3.2/24" ],
-                            "mac"  : "00:00:00:00:00:01"
-                        }
-                    ]
-                },
-                "of:00000000000000b1/4" : {
-                    "interfaces" : [
-                        {
-                            "name" : "b1-4",
-                            "ips"  : [ "10.0.4.2/24" ],
-                            "mac"  : "00:00:00:00:00:02",
-                            "vlan" : "100"
-                        }
-                    ]
-                }
-            },
-            "apps" : {
-                "org.onosproject.router" : {
-                    "router" : {
-                        "controlPlaneConnectPoint" : "of:00000000000000b1/5",
-                        "ospfEnabled" : "true",
-                        "interfaces" : [ "b1-1", "b1-2", "b1-2", "b1-4" ]
-                    }
-                }
-            }
-        }
-        return json.dumps(data, indent=4, sort_keys=True)
-
     def write_configs(self, o):
         o.config_fns = []
         o.rest_configs = []
@@ -399,45 +152,6 @@
             file(os.path.join(o.files_dir, fn),"w").write(" " +value)
             o.early_rest_configs.append( {"endpoint": endpoint, "fn": fn} )
 
-        # Generate config files and save them to the appropriate tenant attributes
-        configs = []
-        for key, value in attrs.iteritems():
-            if key == "autogenerate" and value:
-                for config in value.split(','):
-                    configs.append(config.strip())
-
-        for label in configs:
-            config = None
-            value = None
-            if label == "vtn-network-cfg":
-                # Generate the VTN config file... where should this live?
-                config = "rest_onos/v1/network/configuration/"
-                value = self.get_vtn_config(o, attrs)
-            elif label == "volt-network-cfg":
-                config = "rest_onos/v1/network/configuration/"
-                value = self.get_volt_network_config(o, attrs)
-            elif label == "volt-component-cfg":
-                config = "component_config"
-                value = self.get_volt_component_config(o, attrs)
-            elif label == "vrouter-network-cfg":
-                config = "rest_onos/v1/network/configuration/"
-                value = self.get_vrouter_network_config(o, attrs)
-
-            if config:
-                tas = TenantAttribute.objects.filter(tenant=o, name=config)
-                if tas:
-                    ta = tas[0]
-                    if ta.value != value:
-                        logger.info("updating %s with autogenerated config" % config)
-                        ta.value = value
-                        ta.save()
-                        attrs[config] = value
-                else:
-                    logger.info("saving autogenerated config %s" % config)
-                    ta = TenantAttribute(tenant=o, name=config, value=value)
-                    ta.save()
-                    attrs[config] = value
-
         for name in attrs.keys():
             value = attrs[name]
             if name.startswith("config_"):
