diff --git a/Makefile b/Makefile
index 04b3d31..3fe545a 100644
--- a/Makefile
+++ b/Makefile
@@ -33,8 +33,6 @@
 ROCORE_IMAGENAME           := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-ro-core
 OFAGENT_IMAGENAME          := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-ofagent
 CLI_IMAGENAME              := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-cli
-PONSIMOLT_IMAGENAME        := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-adapter-ponsim-olt
-PONSIMONU_IMAGENAME        := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-adapter-ponsim-onu
 
 ## Docker labels. Only set ref and commit date if committed
 DOCKER_LABEL_VCS_URL       ?= $(shell git remote get-url $(shell git remote))
@@ -68,8 +66,6 @@
 	@echo "ro_core              : Build the ro_core docker image"
 	@echo "ofagent              : Build the openflow agent docker image"
 	@echo "cli                  : Build the voltha CLI docker image"
-	@echo "adapter_ponsim_olt   : Build the ponsim olt adapter docker image"
-	@echo "adapter_ponsim_onu   : Build the ponsim onu adapter docker image"
 	@echo "venv                 : Build local Python virtualenv"
 	@echo "clean                : Remove files created by the build and tests"
 	@echo "distclean            : Remove venv directory"
@@ -123,7 +119,7 @@
 
 build: docker-build
 
-docker-build: rw_core ro_core ofagent cli adapter_ponsim_olt adapter_ponsim_onu
+docker-build: rw_core ro_core ofagent cli
 
 rw_core: local-protos
 	docker build $(DOCKER_BUILD_ARGS) -t ${RWCORE_IMAGENAME}:${DOCKER_TAG} -t ${RWCORE_IMAGENAME}:latest -f docker/Dockerfile.rw_core .
@@ -137,19 +133,11 @@
 cli: local-protos local-pyvoltha
 	docker build $(DOCKER_BUILD_ARGS_LOCAL) -t ${CLI_IMAGENAME}:${DOCKER_TAG} -t ${CLI_IMAGENAME}:latest -f python/docker/Dockerfile.cli python
 
-adapter_ponsim_olt: local-protos local-pyvoltha
-	docker build $(DOCKER_BUILD_ARGS_LOCAL) -t ${PONSIMOLT_IMAGENAME}:${DOCKER_TAG} -t ${PONSIMOLT_IMAGENAME}:latest -f python/docker/Dockerfile.adapter_ponsim_olt python
-
-adapter_ponsim_onu: local-protos local-pyvoltha
-	docker build $(DOCKER_BUILD_ARGS_LOCAL) -t ${PONSIMONU_IMAGENAME}:${DOCKER_TAG} -t ${PONSIMONU_IMAGENAME}:latest -f python/docker/Dockerfile.adapter_ponsim_onu python
-
 docker-push:
 	docker push ${RWCORE_IMAGENAME}:${DOCKER_TAG}
 	docker push ${ROCORE_IMAGENAME}:${DOCKER_TAG}
 	docker push ${OFAGENT_IMAGENAME}:${DOCKER_TAG}
 	docker push ${CLI_IMAGENAME}:${DOCKER_TAG}
-	docker push ${PONSIMOLT_IMAGENAME}:${DOCKER_TAG}
-	docker push ${PONSIMONU_IMAGENAME}:${DOCKER_TAG}
 
 ## lint and unit tests
 
diff --git a/python/adapters/ponsim_olt/VERSION b/python/adapters/ponsim_olt/VERSION
deleted file mode 100644
index 84e6d84..0000000
--- a/python/adapters/ponsim_olt/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-2.2.1-dev
diff --git a/python/adapters/ponsim_olt/__init__.py b/python/adapters/ponsim_olt/__init__.py
deleted file mode 100644
index 4a82628..0000000
--- a/python/adapters/ponsim_olt/__init__.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2018-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
diff --git a/python/adapters/ponsim_olt/main.py b/python/adapters/ponsim_olt/main.py
deleted file mode 100755
index 5a49184..0000000
--- a/python/adapters/ponsim_olt/main.py
+++ /dev/null
@@ -1,495 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2018 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-"""Ponsim OLT Adapter main entry point"""
-
-import argparse
-import os
-import time
-
-import arrow
-import yaml
-from packaging.version import Version
-from simplejson import dumps
-from twisted.internet.defer import inlineCallbacks, returnValue
-from twisted.internet.task import LoopingCall
-from zope.interface import implementer
-
-from pyvoltha.common.structlog_setup import setup_logging, update_logging
-from pyvoltha.common.utils.asleep import asleep
-from pyvoltha.common.utils.deferred_utils import TimeOutError
-from pyvoltha.common.utils.dockerhelpers import get_my_containers_name
-from pyvoltha.common.utils.nethelpers import get_my_primary_local_ipv4, \
-    get_my_primary_interface
-from pyvoltha.common.utils.registry import registry, IComponent
-from pyvoltha.adapters.kafka.adapter_proxy import AdapterProxy
-from pyvoltha.adapters.kafka.adapter_request_facade import AdapterRequestFacade
-from pyvoltha.adapters.kafka.core_proxy import CoreProxy
-from pyvoltha.adapters.kafka.kafka_inter_container_library import IKafkaMessagingProxy, \
-    get_messaging_proxy
-from pyvoltha.adapters.kafka.kafka_proxy import KafkaProxy, get_kafka_proxy
-from ponsim_olt import PonSimOltAdapter
-from voltha_protos.adapter_pb2 import AdapterConfig
-
-defs = dict(
-    version_file='./VERSION',
-    config=os.environ.get('CONFIG', './ponsim_olt.yml'),
-    container_name_regex=os.environ.get('CONTAINER_NUMBER_EXTRACTOR', '^.*\.(['
-                                                                      '0-9]+)\..*$'),
-    consul=os.environ.get('CONSUL', 'localhost:8500'),
-    name=os.environ.get('NAME', 'ponsim_olt'),
-    vendor=os.environ.get('VENDOR', 'Voltha Project'),
-    device_type=os.environ.get('DEVICE_TYPE', 'ponsim_olt'),
-    accept_bulk_flow=os.environ.get('ACCEPT_BULK_FLOW', True),
-    accept_atomic_flow=os.environ.get('ACCEPT_ATOMIC_FLOW', True),
-    etcd=os.environ.get('ETCD', 'localhost:2379'),
-    core_topic=os.environ.get('CORE_TOPIC', 'rwcore'),
-    interface=os.environ.get('INTERFACE', get_my_primary_interface()),
-    instance_id=os.environ.get('INSTANCE_ID', os.environ.get('HOSTNAME', '1')),
-    kafka_adapter=os.environ.get('KAFKA_ADAPTER', '172.20.10.3:9092'),
-    kafka_cluster=os.environ.get('KAFKA_CLUSTER', '172.20.10.3:9092'),
-    backend=os.environ.get('BACKEND', 'none'),
-    retry_interval=os.environ.get('RETRY_INTERVAL', 2),
-    heartbeat_topic=os.environ.get('HEARTBEAT_TOPIC', "adapters.heartbeat"),
-)
-
-
-def parse_args():
-    parser = argparse.ArgumentParser()
-
-    _help = ('Path to ponsim_onu.yml config file (default: %s). '
-             'If relative, it is relative to main.py of ponsim adapter.'
-             % defs['config'])
-    parser.add_argument('-c', '--config',
-                        dest='config',
-                        action='store',
-                        default=defs['config'],
-                        help=_help)
-
-    _help = 'Regular expression for extracting conatiner number from ' \
-            'container name (default: %s)' % defs['container_name_regex']
-    parser.add_argument('-X', '--container-number-extractor',
-                        dest='container_name_regex',
-                        action='store',
-                        default=defs['container_name_regex'],
-                        help=_help)
-
-    _help = '<hostname>:<port> to consul agent (default: %s)' % defs['consul']
-    parser.add_argument('-C', '--consul',
-                        dest='consul',
-                        action='store',
-                        default=defs['consul'],
-                        help=_help)
-
-    _help = 'name of this adapter (default: %s)' % defs['name']
-    parser.add_argument('-na', '--name',
-                        dest='name',
-                        action='store',
-                        default=defs['name'],
-                        help=_help)
-
-    _help = 'vendor of this adapter (default: %s)' % defs['vendor']
-    parser.add_argument('-ven', '--vendor',
-                        dest='vendor',
-                        action='store',
-                        default=defs['vendor'],
-                        help=_help)
-
-    _help = 'supported device type of this adapter (default: %s)' % defs[
-        'device_type']
-    parser.add_argument('-dt', '--device_type',
-                        dest='device_type',
-                        action='store',
-                        default=defs['device_type'],
-                        help=_help)
-
-    _help = 'specifies whether the device type accepts bulk flow updates ' \
-            'adapter (default: %s)' % defs['accept_bulk_flow']
-    parser.add_argument('-abf', '--accept_bulk_flow',
-                        dest='accept_bulk_flow',
-                        action='store',
-                        default=defs['accept_bulk_flow'],
-                        help=_help)
-
-    _help = 'specifies whether the device type accepts add/remove flow ' \
-            '(default: %s)' % defs['accept_atomic_flow']
-    parser.add_argument('-aaf', '--accept_atomic_flow',
-                        dest='accept_atomic_flow',
-                        action='store',
-                        default=defs['accept_atomic_flow'],
-                        help=_help)
-
-    _help = '<hostname>:<port> to etcd server (default: %s)' % defs['etcd']
-    parser.add_argument('-e', '--etcd',
-                        dest='etcd',
-                        action='store',
-                        default=defs['etcd'],
-                        help=_help)
-
-    _help = ('unique string id of this container instance (default: %s)'
-             % defs['instance_id'])
-    parser.add_argument('-i', '--instance-id',
-                        dest='instance_id',
-                        action='store',
-                        default=defs['instance_id'],
-                        help=_help)
-
-    _help = 'ETH interface to recieve (default: %s)' % defs['interface']
-    parser.add_argument('-I', '--interface',
-                        dest='interface',
-                        action='store',
-                        default=defs['interface'],
-                        help=_help)
-
-    _help = 'omit startup banner log lines'
-    parser.add_argument('-n', '--no-banner',
-                        dest='no_banner',
-                        action='store_true',
-                        default=False,
-                        help=_help)
-
-    _help = 'do not emit periodic heartbeat log messages'
-    parser.add_argument('-N', '--no-heartbeat',
-                        dest='no_heartbeat',
-                        action='store_true',
-                        default=False,
-                        help=_help)
-
-    _help = "suppress debug and info logs"
-    parser.add_argument('-q', '--quiet',
-                        dest='quiet',
-                        action='count',
-                        help=_help)
-
-    _help = 'enable verbose logging'
-    parser.add_argument('-v', '--verbose',
-                        dest='verbose',
-                        action='count',
-                        help=_help)
-
-    _help = ('use docker container name as conatiner instance id'
-             ' (overrides -i/--instance-id option)')
-    parser.add_argument('--instance-id-is-container-name',
-                        dest='instance_id_is_container_name',
-                        action='store_true',
-                        default=False,
-                        help=_help)
-
-    _help = ('<hostname>:<port> of the kafka adapter broker (default: %s). ('
-             'If not '
-             'specified (None), the address from the config file is used'
-             % defs['kafka_adapter'])
-    parser.add_argument('-KA', '--kafka_adapter',
-                        dest='kafka_adapter',
-                        action='store',
-                        default=defs['kafka_adapter'],
-                        help=_help)
-
-    _help = ('<hostname>:<port> of the kafka cluster broker (default: %s). ('
-             'If not '
-             'specified (None), the address from the config file is used'
-             % defs['kafka_cluster'])
-    parser.add_argument('-KC', '--kafka_cluster',
-                        dest='kafka_cluster',
-                        action='store',
-                        default=defs['kafka_cluster'],
-                        help=_help)
-
-    _help = 'backend to use for config persitence'
-    parser.add_argument('-b', '--backend',
-                        default=defs['backend'],
-                        choices=['none', 'consul', 'etcd'],
-                        help=_help)
-
-    _help = 'topic of core on the kafka bus'
-    parser.add_argument('-ct', '--core_topic',
-                        dest='core_topic',
-                        action='store',
-                        default=defs['core_topic'],
-                        help=_help)
-
-    args = parser.parse_args()
-
-    # post-processing
-
-    if args.instance_id_is_container_name:
-        args.instance_id = get_my_containers_name()
-
-    return args
-
-
-def load_config(args):
-    path = args.config
-    if path.startswith('.'):
-        dir = os.path.dirname(os.path.abspath(__file__))
-        path = os.path.join(dir, path)
-    path = os.path.abspath(path)
-    with open(path) as fd:
-        config = yaml.load(fd)
-    return config
-
-
-def print_banner(log):
-    log.info(' ____                 _              ___  _   _____   ')
-    log.info('|  _ \ ___  _ __  ___(_)_ __ ___    / _ \| | |_   _|  ')
-    log.info('| |_) / _ \| \'_ \/ __| | \'_ ` _ \  | | | | |   | |  ')
-    log.info('|  __/ (_) | | | \__ \ | | | | | | | |_| | |___| |    ')
-    log.info('|_|   \___/|_| |_|___/_|_| |_| |_|  \___/|_____|_|    ')
-    log.info('                                                      ')
-    log.info('   _       _             _                            ')
-    log.info('  / \   __| | __ _ _ __ | |_ ___ _ __                 ')
-    log.info('  / _ \ / _` |/ _` | \'_ \| __/ _ \ \'__|             ')
-    log.info(' / ___ \ (_| | (_| | |_) | ||  __/ |                  ')
-    log.info('/_/   \_\__,_|\__,_| .__/ \__\___|_|                  ')
-    log.info('                   |_|                                ')
-    log.info('(to stop: press Ctrl-C)')
-
-
-@implementer(IComponent)
-class Main(object):
-
-    def __init__(self):
-
-        self.args = args = parse_args()
-        self.config = load_config(args)
-
-        verbosity_adjust = (args.verbose or 0) - (args.quiet or 0)
-        self.log = setup_logging(self.config.get('logging', {}),
-                                 args.instance_id,
-                                 verbosity_adjust=verbosity_adjust)
-        self.log.info('container-number-extractor',
-                      regex=args.container_name_regex)
-
-        self.ponsim_olt_adapter_version = self.get_version()
-        self.log.info('Ponsim-OLT-Adapter-Version', version=
-        self.ponsim_olt_adapter_version)
-
-        if not args.no_banner:
-            print_banner(self.log)
-
-        self.adapter = None
-        # Create a unique instance id using the passed-in instance id and
-        # UTC timestamp
-        current_time = arrow.utcnow().timestamp
-        self.instance_id = self.args.instance_id + '_' + str(current_time)
-
-        self.core_topic = args.core_topic
-        self.listening_topic = args.name
-        self.startup_components()
-
-        if not args.no_heartbeat:
-            self.start_heartbeat()
-            self.start_kafka_cluster_heartbeat(self.instance_id)
-
-    def get_version(self):
-        path = defs['version_file']
-        if not path.startswith('/'):
-            dir = os.path.dirname(os.path.abspath(__file__))
-            path = os.path.join(dir, path)
-
-        path = os.path.abspath(path)
-        version_file = open(path, 'r')
-        v = version_file.read()
-
-        # Use Version to validate the version string - exception will be raised
-        # if the version is invalid
-        Version(v)
-
-        version_file.close()
-        return v
-
-    def start(self):
-        self.start_reactor()  # will not return except Keyboard interrupt
-
-    def stop(self):
-        pass
-
-    def get_args(self):
-        """Allow access to command line args"""
-        return self.args
-
-    def get_config(self):
-        """Allow access to content of config file"""
-        return self.config
-
-    def _get_adapter_config(self):
-        cfg = AdapterConfig()
-        return cfg
-
-    @inlineCallbacks
-    def startup_components(self):
-        try:
-            self.log.info('starting-internal-components',
-                          consul=self.args.consul,
-                          etcd=self.args.etcd)
-
-            registry.register('main', self)
-
-            # Update the logger to output the vcore id.
-            self.log = update_logging(instance_id=self.instance_id,
-                                      vcore_id=None)
-
-            yield registry.register(
-                'kafka_cluster_proxy',
-                KafkaProxy(
-                    self.args.consul,
-                    self.args.kafka_cluster,
-                    config=self.config.get('kafka-cluster-proxy', {})
-                )
-            ).start()
-
-            config = self._get_adapter_config()
-
-            self.core_proxy = CoreProxy(
-                kafka_proxy=None,
-                default_core_topic=self.core_topic,
-                my_listening_topic=self.listening_topic)
-
-            self.adapter_proxy = AdapterProxy(
-                kafka_proxy=None,
-                core_topic=self.core_topic,
-                my_listening_topic=self.listening_topic)
-
-            self.adapter = PonSimOltAdapter(core_proxy=self.core_proxy,
-                                            adapter_proxy=self.adapter_proxy,
-                                            config=config)
-
-            ponsim_request_handler = AdapterRequestFacade(adapter=self.adapter,
-                                                    core_proxy=self.core_proxy)
-
-            yield registry.register(
-                'kafka_adapter_proxy',
-                IKafkaMessagingProxy(
-                    kafka_host_port=self.args.kafka_adapter,
-                    # TODO: Add KV Store object reference
-                    kv_store=self.args.backend,
-                    default_topic=self.args.name,
-                    group_id_prefix=self.args.instance_id,
-                    target_cls=ponsim_request_handler
-                )
-            ).start()
-
-            self.core_proxy.kafka_proxy = get_messaging_proxy()
-            self.adapter_proxy.kafka_proxy = get_messaging_proxy()
-
-            # retry for ever
-            res = yield self._register_with_core(-1)
-
-            self.log.info('started-internal-services')
-
-        except Exception as e:
-            self.log.exception('Failure-to-start-all-components', e=e)
-
-    @inlineCallbacks
-    def shutdown_components(self):
-        """Execute before the reactor is shut down"""
-        self.log.info('exiting-on-keyboard-interrupt')
-        for component in reversed(registry.iterate()):
-            yield component.stop()
-
-        import threading
-        self.log.info('THREADS:')
-        main_thread = threading.current_thread()
-        for t in threading.enumerate():
-            if t is main_thread:
-                continue
-            if not t.isDaemon():
-                continue
-            self.log.info('joining thread {} {}'.format(
-                t.getName(), "daemon" if t.isDaemon() else "not-daemon"))
-            t.join()
-
-    def start_reactor(self):
-        from twisted.internet import reactor
-        reactor.callWhenRunning(
-            lambda: self.log.info('twisted-reactor-started'))
-        reactor.addSystemEventTrigger('before', 'shutdown',
-                                      self.shutdown_components)
-        reactor.run()
-
-    @inlineCallbacks
-    def _register_with_core(self, retries):
-        while 1:
-            try:
-                resp = yield self.core_proxy.register(
-                    self.adapter.adapter_descriptor(),
-                    self.adapter.device_types())
-                if resp:
-                    self.log.info('registered-with-core',
-                                  coreId=resp.instance_id)
-                returnValue(resp)
-            except TimeOutError as e:
-                self.log.warn("timeout-when-registering-with-core", e=e)
-                if retries == 0:
-                    self.log.exception("no-more-retries", e=e)
-                    raise
-                else:
-                    retries = retries if retries < 0 else retries - 1
-                    yield asleep(defs['retry_interval'])
-            except Exception as e:
-                self.log.exception("failed-registration", e=e)
-                raise
-
-    def start_heartbeat(self):
-
-        t0 = time.time()
-        t0s = time.ctime(t0)
-
-        def heartbeat():
-            self.log.debug(status='up', since=t0s, uptime=time.time() - t0)
-
-        lc = LoopingCall(heartbeat)
-        lc.start(10)
-
-    # Temporary function to send a heartbeat message to the external kafka
-    # broker
-    def start_kafka_cluster_heartbeat(self, instance_id):
-        # For heartbeat we will send a message to a specific "voltha-heartbeat"
-        #  topic.  The message is a protocol buf
-        # message
-        message = dict(
-            type='heartbeat',
-            adapter=self.args.name,
-            instance=instance_id,
-            ip=get_my_primary_local_ipv4()
-        )
-        topic = defs['heartbeat_topic']
-
-        def send_msg(start_time):
-            try:
-                kafka_cluster_proxy = get_kafka_proxy()
-                if kafka_cluster_proxy and not kafka_cluster_proxy.is_faulty():
-                    # self.log.debug('kafka-proxy-available')
-                    message['ts'] = arrow.utcnow().timestamp
-                    message['uptime'] = time.time() - start_time
-                    # self.log.debug('start-kafka-heartbeat')
-                    kafka_cluster_proxy.send_message(topic, dumps(message))
-                else:
-                    self.log.error('kafka-proxy-unavailable')
-            except Exception, e:
-                self.log.exception('failed-sending-message-heartbeat', e=e)
-
-        try:
-            t0 = time.time()
-            lc = LoopingCall(send_msg, t0)
-            lc.start(10)
-        except Exception, e:
-            self.log.exception('failed-kafka-heartbeat', e=e)
-
-
-if __name__ == '__main__':
-    Main().start()
diff --git a/python/adapters/ponsim_olt/ponsim_olt.py b/python/adapters/ponsim_olt/ponsim_olt.py
deleted file mode 100644
index c99fcac..0000000
--- a/python/adapters/ponsim_olt/ponsim_olt.py
+++ /dev/null
@@ -1,665 +0,0 @@
-#
-# Copyright 2017 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-"""
-Fully simulated OLT adapter.
-"""
-
-import arrow
-import grpc
-import structlog
-from google.protobuf.empty_pb2 import Empty
-from google.protobuf.json_format import MessageToDict
-from scapy.layers.inet import Raw
-import json
-from google.protobuf.message import Message
-from grpc._channel import _Rendezvous
-from scapy.layers.l2 import Ether, Dot1Q
-from simplejson import dumps
-from twisted.internet import reactor
-from twisted.internet.defer import inlineCallbacks, returnValue
-from twisted.internet.task import LoopingCall
-
-from pyvoltha.adapters.common.frameio.frameio import BpfProgramFilter, hexify
-from pyvoltha.common.utils.asleep import asleep
-from pyvoltha.common.utils.registry import registry
-from pyvoltha.adapters.iadapter import OltAdapter
-from pyvoltha.adapters.kafka.kafka_proxy import get_kafka_proxy
-from voltha_protos.ponsim_pb2_grpc import PonSimStub
-from voltha_protos.common_pb2 import OperStatus, ConnectStatus
-from voltha_protos.inter_container_pb2 import SwitchCapability, PortCapability, \
-    InterAdapterMessageType, InterAdapterResponseBody
-from voltha_protos.device_pb2 import Port, PmConfig, PmConfigs
-from voltha_protos.events_pb2 import KpiEvent, KpiEventType, MetricValuePairs
-from voltha_protos.logical_device_pb2 import LogicalPort
-from voltha_protos.openflow_13_pb2 import OFPPS_LIVE, OFPPF_FIBER, \
-    OFPPF_1GB_FD, \
-    OFPC_GROUP_STATS, OFPC_PORT_STATS, OFPC_TABLE_STATS, OFPC_FLOW_STATS, \
-    ofp_switch_features, ofp_desc
-from voltha_protos.openflow_13_pb2 import ofp_port
-from voltha_protos.ponsim_pb2 import FlowTable, PonSimFrame, PonSimMetricsRequest
-
-log = structlog.get_logger()
-
-PACKET_IN_VLAN = 4000
-is_inband_frame = BpfProgramFilter('(ether[14:2] & 0xfff) = 0x{:03x}'.format(
-    PACKET_IN_VLAN))
-
-
-def mac_str_to_tuple(mac):
-    return tuple(int(d, 16) for d in mac.split(':'))
-
-
-class AdapterPmMetrics:
-    def __init__(self, device):
-        self.pm_names = {'tx_64_pkts', 'tx_65_127_pkts', 'tx_128_255_pkts',
-                         'tx_256_511_pkts', 'tx_512_1023_pkts',
-                         'tx_1024_1518_pkts', 'tx_1519_9k_pkts',
-                         'rx_64_pkts', 'rx_65_127_pkts',
-                         'rx_128_255_pkts', 'rx_256_511_pkts',
-                         'rx_512_1023_pkts', 'rx_1024_1518_pkts',
-                         'rx_1519_9k_pkts'}
-        self.device = device
-        self.id = device.id
-        self.name = 'ponsim_olt'
-        self.default_freq = 150
-        self.grouped = False
-        self.freq_override = False
-        self.pon_metrics_config = dict()
-        self.nni_metrics_config = dict()
-        self.lc = None
-        for m in self.pm_names:
-            self.pon_metrics_config[m] = PmConfig(name=m,
-                                                  type=PmConfig.COUNTER,
-                                                  enabled=True)
-            self.nni_metrics_config[m] = PmConfig(name=m,
-                                                  type=PmConfig.COUNTER,
-                                                  enabled=True)
-
-    def update(self, pm_config):
-        if self.default_freq != pm_config.default_freq:
-            # Update the callback to the new frequency.
-            self.default_freq = pm_config.default_freq
-            self.lc.stop()
-            self.lc.start(interval=self.default_freq / 10)
-        for m in pm_config.metrics:
-            self.pon_metrics_config[m.name].enabled = m.enabled
-            self.nni_metrics_config[m.name].enabled = m.enabled
-
-    def make_proto(self):
-        pm_config = PmConfigs(
-            id=self.id,
-            default_freq=self.default_freq,
-            grouped=False,
-            freq_override=False)
-        for m in sorted(self.pon_metrics_config):
-            pm = self.pon_metrics_config[m]  # Either will do they're the same
-            pm_config.metrics.extend([PmConfig(name=pm.name,
-                                               type=pm.type,
-                                               enabled=pm.enabled)])
-        return pm_config
-
-    def collect_port_metrics(self, channel):
-        rtrn_port_metrics = dict()
-        stub = PonSimStub(channel)
-        stats = stub.GetStats(Empty())
-        rtrn_port_metrics['pon'] = self.extract_pon_metrics(stats)
-        rtrn_port_metrics['nni'] = self.extract_nni_metrics(stats)
-        return rtrn_port_metrics
-
-    def extract_pon_metrics(self, stats):
-        rtrn_pon_metrics = dict()
-        for m in stats.metrics:
-            if m.port_name == "pon":
-                for p in m.packets:
-                    if self.pon_metrics_config[p.name].enabled:
-                        rtrn_pon_metrics[p.name] = p.value
-                return rtrn_pon_metrics
-
-    def extract_nni_metrics(self, stats):
-        rtrn_pon_metrics = dict()
-        for m in stats.metrics:
-            if m.port_name == "nni":
-                for p in m.packets:
-                    if self.pon_metrics_config[p.name].enabled:
-                        rtrn_pon_metrics[p.name] = p.value
-                return rtrn_pon_metrics
-
-    def start_collector(self, callback):
-        log.info("starting-pm-collection", device_name=self.name,
-                 device_id=self.device.id)
-        prefix = 'voltha.{}.{}'.format(self.name, self.device.id)
-        self.lc = LoopingCall(callback, self.device.id, prefix)
-        self.lc.start(interval=self.default_freq / 10)
-
-    def stop_collector(self):
-        log.info("stopping-pm-collection", device_name=self.name,
-                 device_id=self.device.id)
-        self.lc.stop()
-
-
-class AdapterAlarms:
-    def __init__(self, adapter, device):
-        self.adapter = adapter
-        self.device = device
-        self.lc = None
-
-    # TODO: Implement code to send to kafka cluster directly instead of
-    # going through the voltha core.
-    def send_alarm(self, context_data, alarm_data):
-        log.debug("send-alarm-not-implemented")
-        return
-
-
-class PonSimOltAdapter(OltAdapter):
-    def __init__(self, core_proxy, adapter_proxy, config):
-        super(PonSimOltAdapter, self).__init__(core_proxy=core_proxy,
-                                               adapter_proxy=adapter_proxy,
-                                               config=config,
-                                               device_handler_class=PonSimOltHandler,
-                                               name='ponsim_olt',
-                                               vendor='Voltha project',
-                                               version='0.4',
-                                               device_type='ponsim_olt',
-                                               accepts_bulk_flow_update=True,
-                                               accepts_add_remove_flow_updates=False)
-
-    def update_pm_config(self, device, pm_config):
-        log.info("adapter-update-pm-config", device=device,
-                 pm_config=pm_config)
-        handler = self.devices_handlers[device.id]
-        handler.update_pm_config(device, pm_config)
-
-
-class PonSimOltHandler(object):
-    def __init__(self, adapter, device_id):
-        self.adapter = adapter
-        self.core_proxy = adapter.core_proxy
-        self.adapter_proxy = adapter.adapter_proxy
-        self.device_id = device_id
-        self.log = structlog.get_logger(device_id=device_id)
-        self.channel = None
-        self.io_port = None
-        self.logical_device_id = None
-        self.nni_port = None
-        self.ofp_port_no = None
-        self.interface = registry('main').get_args().interface
-        self.pm_metrics = None
-        self.alarms = None
-        self.frames = None
-
-    @inlineCallbacks
-    def get_channel(self):
-        if self.channel is None:
-            try:
-                device = yield self.core_proxy.get_device(self.device_id)
-                self.log.info('device-info', device=device,
-                              host_port=device.host_and_port)
-                self.channel = grpc.insecure_channel(device.host_and_port)
-            except Exception as e:
-                log.exception("ponsim-connection-failure", e=e)
-
-        # returnValue(self.channel)
-
-    def close_channel(self):
-        if self.channel is None:
-            self.log.info('grpc-channel-already-closed')
-            return
-        else:
-            if self.frames is not None:
-                self.frames.cancel()
-                self.frames = None
-                self.log.info('cancelled-grpc-frame-stream')
-
-            self.channel.unsubscribe(lambda *args: None)
-            self.channel = None
-
-            self.log.info('grpc-channel-closed')
-
-    @inlineCallbacks
-    def _get_nni_port(self):
-        ports = yield self.core_proxy.get_ports(self.device_id,
-                                                Port.ETHERNET_NNI)
-        returnValue(ports)
-
-    @inlineCallbacks
-    def activate(self, device):
-        try:
-            self.log.info('activating')
-
-            if not device.host_and_port:
-                device.oper_status = OperStatus.FAILED
-                device.reason = 'No host_and_port field provided'
-                self.core_proxy.device_update(device)
-                return
-
-            yield self.get_channel()
-            stub = PonSimStub(self.channel)
-            info = stub.GetDeviceInfo(Empty())
-            log.info('got-info', info=info, device_id=device.id)
-            self.ofp_port_no = info.nni_port
-
-            device.root = True
-            device.vendor = 'ponsim'
-            device.model = 'n/a'
-            device.serial_number = device.host_and_port
-            device.mac_address = "AA:BB:CC:DD:EE:FF"
-            yield self.core_proxy.device_update(device)
-
-            # Now set the initial PM configuration for this device
-            self.pm_metrics = AdapterPmMetrics(device)
-            pm_config = self.pm_metrics.make_proto()
-            log.info("initial-pm-config", pm_config=pm_config)
-            yield self.core_proxy.device_pm_config_update(pm_config, init=True)
-
-            # Setup alarm handler
-            self.alarms = AdapterAlarms(self.adapter, device)
-
-            nni_port = Port(
-                port_no=info.nni_port,
-                label='nni-'+ str(info.nni_port),
-                type=Port.ETHERNET_NNI,
-                oper_status=OperStatus.ACTIVE
-            )
-            self.nni_port = nni_port
-            yield self.core_proxy.port_created(device.id, nni_port)
-            yield self.core_proxy.port_created(device.id, Port(
-                port_no=1,
-                label='pon-1',
-                type=Port.PON_OLT,
-                oper_status=OperStatus.ACTIVE
-            ))
-
-            yield self.core_proxy.device_state_update(device.id,
-                                                      connect_status=ConnectStatus.REACHABLE,
-                                                      oper_status=OperStatus.ACTIVE)
-
-            # register ONUS
-            self.log.info('onu-found', onus=info.onus, len=len(info.onus))
-            for onu in info.onus:
-                vlan_id = onu.uni_port
-                yield self.core_proxy.child_device_detected(
-                    parent_device_id=device.id,
-                    parent_port_no=1,
-                    child_device_type='ponsim_onu',
-                    channel_id=vlan_id,
-                    serial_number=onu.serial_number,
-                )
-
-            self.log.info('starting-frame-grpc-stream')
-            reactor.callInThread(self.rcv_grpc)
-            self.log.info('started-frame-grpc-stream')
-
-            # Start collecting stats from the device after a brief pause
-            self.start_kpi_collection(device.id)
-        except Exception as e:
-            log.exception("Exception-activating", e=e)
-
-    def get_ofp_device_info(self, device):
-        return SwitchCapability(
-            desc=ofp_desc(
-                hw_desc='ponsim pon',
-                sw_desc='ponsim pon',
-                serial_num=device.serial_number,
-                mfr_desc="VOLTHA Project",
-                dp_desc='n/a'
-            ),
-            switch_features=ofp_switch_features(
-                n_buffers=256,  # TODO fake for now
-                n_tables=2,  # TODO ditto
-                capabilities=(  # TODO and ditto
-                        OFPC_FLOW_STATS
-                        | OFPC_TABLE_STATS
-                        | OFPC_PORT_STATS
-                        | OFPC_GROUP_STATS
-                )
-            )
-        )
-
-    def get_ofp_port_info(self, device, port_no):
-        # Since the adapter created the device port then it has the reference of the port to
-        # return the capability.   TODO:  Do a lookup on the NNI port number and return the
-        # appropriate attributes
-        self.log.info('get_ofp_port_info', port_no=port_no,
-                      info=self.ofp_port_no, device_id=device.id)
-        cap = OFPPF_1GB_FD | OFPPF_FIBER
-        return PortCapability(
-            port=LogicalPort(
-                ofp_port=ofp_port(
-                    hw_addr=mac_str_to_tuple(
-                        'AA:BB:CC:DD:EE:%02x' % port_no),
-                    config=0,
-                    state=OFPPS_LIVE,
-                    curr=cap,
-                    advertised=cap,
-                    peer=cap,
-                    curr_speed=OFPPF_1GB_FD,
-                    max_speed=OFPPF_1GB_FD
-                ),
-                device_id=device.id,
-                device_port_no=port_no
-            )
-        )
-
-    # TODO - change for core 2.0
-    def reconcile(self, device):
-        self.log.info('reconciling-OLT-device')
-
-    @inlineCallbacks
-    def _rcv_frame(self, frame):
-        pkt = Ether(frame)
-
-        if pkt.haslayer(Dot1Q):
-            outer_shim = pkt.getlayer(Dot1Q)
-
-            if isinstance(outer_shim.payload, Dot1Q):
-                inner_shim = outer_shim.payload
-                cvid = inner_shim.vlan
-                popped_frame = (
-                        Ether(src=pkt.src, dst=pkt.dst, type=inner_shim.type) /
-                        inner_shim.payload
-                )
-                self.log.info('sending-packet-in',device_id=self.device_id, port=cvid)
-                yield self.core_proxy.send_packet_in(device_id=self.device_id,
-                                               port=cvid,
-                                               packet=str(popped_frame))
-            elif pkt.haslayer(Raw):
-                raw_data = json.loads(pkt.getlayer(Raw).load)
-                self.alarms.send_alarm(self, raw_data)
-
-    @inlineCallbacks
-    def rcv_grpc(self):
-        """
-        This call establishes a GRPC stream to receive frames.
-        """
-        yield self.get_channel()
-        stub = PonSimStub(self.channel)
-
-        # Attempt to establish a grpc stream with the remote ponsim service
-        self.frames = stub.ReceiveFrames(Empty())
-
-        self.log.info('start-receiving-grpc-frames')
-
-        try:
-            for frame in self.frames:
-                self.log.info('received-grpc-frame',
-                              frame_len=len(frame.payload))
-                self._rcv_frame(frame.payload)
-
-        except _Rendezvous, e:
-            log.warn('grpc-connection-lost', message=e.message)
-
-        self.log.info('stopped-receiving-grpc-frames')
-
-    @inlineCallbacks
-    def update_flow_table(self, flows):
-        yield self.get_channel()
-        stub = PonSimStub(self.channel)
-
-        self.log.info('pushing-olt-flow-table')
-        stub.UpdateFlowTable(FlowTable(
-            port=0,
-            flows=flows
-        ))
-        self.log.info('success')
-
-    def remove_from_flow_table(self, flows):
-        self.log.debug('remove-from-flow-table', flows=flows)
-        # TODO: Update PONSIM code to accept incremental flow changes
-        # Once completed, the accepts_add_remove_flow_updates for this
-        # device type can be set to True
-
-    def add_to_flow_table(self, flows):
-        self.log.debug('add-to-flow-table', flows=flows)
-        # TODO: Update PONSIM code to accept incremental flow changes
-        # Once completed, the accepts_add_remove_flow_updates for this
-        # device type can be set to True
-
-    def update_pm_config(self, device, pm_config):
-        log.info("handler-update-pm-config", device=device,
-                 pm_config=pm_config)
-        self.pm_metrics.update(pm_config)
-
-    def send_proxied_message(self, proxy_address, msg):
-        self.log.info('sending-proxied-message')
-        if isinstance(msg, FlowTable):
-            stub = PonSimStub(self.get_channel())
-            self.log.info('pushing-onu-flow-table', port=msg.port)
-            res = stub.UpdateFlowTable(msg)
-            self.core_proxy.receive_proxied_message(proxy_address, res)
-
-    @inlineCallbacks
-    def process_inter_adapter_message(self, request):
-        self.log.info('process-inter-adapter-message', msg=request)
-        try:
-            if request.header.type == InterAdapterMessageType.FLOW_REQUEST:
-                f = FlowTable()
-                if request.body:
-                    request.body.Unpack(f)
-                    stub = PonSimStub(self.channel)
-                    self.log.info('pushing-onu-flow-table')
-                    res = stub.UpdateFlowTable(f)
-                    # Send response back
-                    reply = InterAdapterResponseBody()
-                    reply.status = True
-                    self.log.info('sending-response-back', reply=reply)
-                    yield self.adapter_proxy.send_inter_adapter_message(
-                        msg=reply,
-                        type=InterAdapterMessageType.FLOW_RESPONSE,
-                        from_adapter=self.adapter.name,
-                        to_adapter=request.header.from_topic,
-                        to_device_id=request.header.to_device_id,
-                        message_id=request.header.id
-                    )
-            elif request.header.type == InterAdapterMessageType.METRICS_REQUEST:
-                m = PonSimMetricsRequest()
-                if request.body:
-                    request.body.Unpack(m)
-                    stub = PonSimStub(self.channel)
-                    self.log.info('proxying onu stats request', port=m.port)
-                    res = stub.GetStats(m)
-                    # Send response back
-                    reply = InterAdapterResponseBody()
-                    reply.status = True
-                    reply.body.Pack(res)
-                    self.log.info('sending-response-back', reply=reply)
-                    yield self.adapter_proxy.send_inter_adapter_message(
-                        msg=reply,
-                        type=InterAdapterMessageType.METRICS_RESPONSE,
-                        from_adapter=self.adapter.name,
-                        to_adapter=request.header.from_topic,
-                        to_device_id=request.header.to_device_id,
-                        message_id=request.header.id
-                    )
-        except Exception as e:
-            self.log.exception("error-processing-inter-adapter-message", e=e)
-
-    def packet_out(self, egress_port, msg):
-        self.log.info('sending-packet-out', egress_port=egress_port,
-                      msg=hexify(msg))
-        try:
-            pkt = Ether(msg)
-            out_pkt = pkt
-            if egress_port != self.nni_port.port_no:
-                # don't do the vlan manipulation for the NNI port, vlans are already correct
-                out_pkt = (
-                        Ether(src=pkt.src, dst=pkt.dst) /
-                        Dot1Q(vlan=egress_port, type=pkt.type) /
-                        pkt.payload
-                )
-
-            # TODO need better way of mapping logical ports to PON ports
-            out_port = self.nni_port.port_no if egress_port == self.nni_port.port_no else 1
-
-            # send over grpc stream
-            stub = PonSimStub(self.channel)
-            frame = PonSimFrame(id=self.device_id, payload=str(out_pkt),
-                                out_port=out_port)
-            stub.SendFrame(frame)
-        except Exception as e:
-            self.log.exception("error-processing-packet-out", e=e)
-
-
-    @inlineCallbacks
-    def reboot(self):
-        self.log.info('rebooting', device_id=self.device_id)
-
-        yield self.core_proxy.device_state_update(self.device_id,
-                                                  connect_status=ConnectStatus.UNREACHABLE)
-
-        # Update the child devices connect state to UNREACHABLE
-        yield self.core_proxy.children_state_update(self.device_id,
-                                                    connect_status=ConnectStatus.UNREACHABLE)
-
-        # Sleep 10 secs, simulating a reboot
-        # TODO: send alert and clear alert after the reboot
-        yield asleep(10)
-
-        # Change the connection status back to REACHABLE.  With a
-        # real OLT the connection state must be the actual state
-        yield self.core_proxy.device_state_update(self.device_id,
-                                                  connect_status=ConnectStatus.REACHABLE)
-
-        # Update the child devices connect state to REACHABLE
-        yield self.core_proxy.children_state_update(self.device_id,
-                                                    connect_status=ConnectStatus.REACHABLE)
-
-        self.log.info('rebooted', device_id=self.device_id)
-
-    def self_test_device(self, device):
-        """
-        This is called to Self a device based on a NBI call.
-        :param device: A Voltha.Device object.
-        :return: Will return result of self test
-        """
-        log.info('self-test-device', device=device.id)
-        raise NotImplementedError()
-
-    @inlineCallbacks
-    def disable(self):
-        self.log.info('disabling', device_id=self.device_id)
-
-        self.stop_kpi_collection()
-
-        # Update the operational status to UNKNOWN and connection status to UNREACHABLE
-        yield self.core_proxy.device_state_update(self.device_id,
-                                                  oper_status=OperStatus.UNKNOWN,
-                                                  connect_status=ConnectStatus.UNREACHABLE)
-
-        self.close_channel()
-        self.log.info('disabled-grpc-channel')
-
-        self.stop_kpi_collection()
-
-        # TODO:
-        # 1) Remove all flows from the device
-        # 2) Remove the device from ponsim
-
-        self.log.info('disabled', device_id=self.device_id)
-
-    @inlineCallbacks
-    def reenable(self):
-        self.log.info('re-enabling', device_id=self.device_id)
-
-        # Set the ofp_port_no and nni_port in case we bypassed the reconcile
-        # process if the device was in DISABLED state on voltha restart
-        if not self.ofp_port_no and not self.nni_port:
-            yield self.get_channel()
-            stub = PonSimStub(self.channel)
-            info = stub.GetDeviceInfo(Empty())
-            log.info('got-info', info=info)
-            self.ofp_port_no = info.nni_port
-            ports = yield self._get_nni_port()
-            # For ponsim, we are using only 1 NNI port
-            if ports.items:
-                self.nni_port = ports.items[0]
-
-        # Update the state of the NNI port
-        yield self.core_proxy.port_state_update(self.device_id,
-                                                port_type=Port.ETHERNET_NNI,
-                                                port_no=self.ofp_port_no,
-                                                oper_status=OperStatus.ACTIVE)
-
-        # Update the state of the PON port
-        yield self.core_proxy.port_state_update(self.device_id,
-                                                port_type=Port.PON_OLT,
-                                                port_no=1,
-                                                oper_status=OperStatus.ACTIVE)
-
-        # Set the operational state of the device to ACTIVE and connect status to REACHABLE
-        yield self.core_proxy.device_state_update(self.device_id,
-                                                  connect_status=ConnectStatus.REACHABLE,
-                                                  oper_status=OperStatus.ACTIVE)
-
-        # TODO: establish frame grpc-stream
-        # yield reactor.callInThread(self.rcv_grpc)
-
-        self.start_kpi_collection(self.device_id)
-
-        self.log.info('re-enabled', device_id=self.device_id)
-
-    def delete(self):
-        self.log.info('deleting', device_id=self.device_id)
-
-        self.close_channel()
-        self.log.info('disabled-grpc-channel')
-
-        # TODO:
-        # 1) Remove all flows from the device
-        # 2) Remove the device from ponsim
-
-        self.log.info('deleted', device_id=self.device_id)
-
-    def start_kpi_collection(self, device_id):
-
-        kafka_cluster_proxy = get_kafka_proxy()
-
-        def _collect(device_id, prefix):
-
-            try:
-                # Step 1: gather metrics from device
-                port_metrics = \
-                    self.pm_metrics.collect_port_metrics(self.channel)
-
-                # Step 2: prepare the KpiEvent for submission
-                # we can time-stamp them here (or could use time derived from OLT
-                ts = arrow.utcnow().timestamp
-                kpi_event = KpiEvent(
-                    type=KpiEventType.slice,
-                    ts=ts,
-                    prefixes={
-                        # OLT NNI port
-                        prefix + '.nni': MetricValuePairs(
-                            metrics=port_metrics['nni']),
-                        # OLT PON port
-                        prefix + '.pon': MetricValuePairs(
-                            metrics=port_metrics['pon'])
-                    }
-                )
-
-                # Step 3: submit directly to the kafka bus
-                if kafka_cluster_proxy:
-                    if isinstance(kpi_event, Message):
-                        kpi_event = dumps(MessageToDict(kpi_event, True, True))
-                    kafka_cluster_proxy.send_message("voltha.kpis", kpi_event)
-
-            except Exception as e:
-                log.exception('failed-to-submit-kpis', e=e)
-
-        self.pm_metrics.start_collector(_collect)
-
-    def stop_kpi_collection(self):
-        self.pm_metrics.stop_collector()
diff --git a/python/adapters/ponsim_olt/ponsim_olt.yml b/python/adapters/ponsim_olt/ponsim_olt.yml
deleted file mode 100644
index 7c7fac3..0000000
--- a/python/adapters/ponsim_olt/ponsim_olt.yml
+++ /dev/null
@@ -1,67 +0,0 @@
----
-# Copyright 2018 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-logging:
-    version: 1
-
-    formatters:
-      brief:
-        format: '%(message)s'
-      default:
-        format: '%(asctime)s.%(msecs)03d %(levelname)-8s %(threadName)s %(module)s.%(funcName)s %(message)s'
-        datefmt: '%Y%m%dT%H%M%S'
-
-    handlers:
-        console:
-            class : logging.StreamHandler
-            level: DEBUG
-            formatter: default
-            stream: ext://sys.stdout
-        localRotatingFile:
-            class: logging.handlers.RotatingFileHandler
-            filename: ponsim_olt.log
-            formatter: default
-            maxBytes: 2097152
-            backupCount: 10
-            level: DEBUG
-        null:
-            class: logging.NullHandler
-
-    loggers:
-        amqp:
-            handlers: [null]
-            propagate: False
-        conf:
-            propagate: False
-        '': # root logger
-            handlers: [console, localRotatingFile]
-            level: DEBUG # this can be bumped up/down by -q and -v command line
-                        # options
-            propagate: False
-
-
-kafka-cluster-proxy:
-    event_bus_publisher:
-        topic_mappings:
-            'model-change-events':
-                kafka_topic: 'voltha.events'
-                filters:     [null]
-            'alarms':
-                kafka_topic: 'voltha.alarms'
-                filters:     [null]
-            'kpis':
-                kafka_topic: 'voltha.kpis'
-                filters:     [null]
-
diff --git a/python/adapters/ponsim_onu/VERSION b/python/adapters/ponsim_onu/VERSION
deleted file mode 100644
index 84e6d84..0000000
--- a/python/adapters/ponsim_onu/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-2.2.1-dev
diff --git a/python/adapters/ponsim_onu/__init__.py b/python/adapters/ponsim_onu/__init__.py
deleted file mode 100644
index 4a82628..0000000
--- a/python/adapters/ponsim_onu/__init__.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2018-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
diff --git a/python/adapters/ponsim_onu/main.py b/python/adapters/ponsim_onu/main.py
deleted file mode 100755
index fee9cdd..0000000
--- a/python/adapters/ponsim_onu/main.py
+++ /dev/null
@@ -1,494 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2018 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-"""Ponsim ONU Adapter main entry point"""
-
-import argparse
-import os
-import time
-
-import arrow
-import yaml
-from packaging.version import Version
-from simplejson import dumps
-from twisted.internet.defer import inlineCallbacks, returnValue
-from twisted.internet.task import LoopingCall
-from zope.interface import implementer
-
-from pyvoltha.common.structlog_setup import setup_logging, update_logging
-from pyvoltha.common.utils.asleep import asleep
-from pyvoltha.common.utils.deferred_utils import TimeOutError
-from pyvoltha.common.utils.dockerhelpers import get_my_containers_name
-from pyvoltha.common.utils.nethelpers import get_my_primary_local_ipv4, \
-    get_my_primary_interface
-from pyvoltha.common.utils.registry import registry, IComponent
-from pyvoltha.adapters.kafka.adapter_proxy import AdapterProxy
-from pyvoltha.adapters.kafka.adapter_request_facade import AdapterRequestFacade
-from pyvoltha.adapters.kafka.core_proxy import CoreProxy
-from pyvoltha.adapters.kafka.kafka_inter_container_library import IKafkaMessagingProxy, \
-    get_messaging_proxy
-from pyvoltha.adapters.kafka.kafka_proxy import KafkaProxy, get_kafka_proxy
-from ponsim_onu import PonSimOnuAdapter
-from voltha_protos.adapter_pb2 import AdapterConfig
-
-defs = dict(
-    version_file='./VERSION',
-    config=os.environ.get('CONFIG', './ponsim_onu.yml'),
-    container_name_regex=os.environ.get('CONTAINER_NUMBER_EXTRACTOR', '^.*\.(['
-                                                                      '0-9]+)\..*$'),
-    consul=os.environ.get('CONSUL', 'localhost:8500'),
-    name=os.environ.get('NAME', 'ponsim_onu'),
-    vendor=os.environ.get('VENDOR', 'Voltha Project'),
-    device_type=os.environ.get('DEVICE_TYPE', 'ponsim_onu'),
-    accept_bulk_flow=os.environ.get('ACCEPT_BULK_FLOW', True),
-    accept_atomic_flow=os.environ.get('ACCEPT_ATOMIC_FLOW', True),
-    etcd=os.environ.get('ETCD', 'localhost:2379'),
-    core_topic=os.environ.get('CORE_TOPIC', 'rwcore'),
-    interface=os.environ.get('INTERFACE', get_my_primary_interface()),
-    instance_id=os.environ.get('INSTANCE_ID', os.environ.get('HOSTNAME', '1')),
-    kafka_adapter=os.environ.get('KAFKA_ADAPTER', '192.168.0.20:9092'),
-    kafka_cluster=os.environ.get('KAFKA_CLUSTER', '10.100.198.220:9092'),
-    backend=os.environ.get('BACKEND', 'none'),
-    retry_interval=os.environ.get('RETRY_INTERVAL', 2),
-    heartbeat_topic=os.environ.get('HEARTBEAT_TOPIC', "adapters.heartbeat"),
-)
-
-
-def parse_args():
-    parser = argparse.ArgumentParser()
-
-    _help = ('Path to ponsim_onu.yml config file (default: %s). '
-             'If relative, it is relative to main.py of ponsim adapter.'
-             % defs['config'])
-    parser.add_argument('-c', '--config',
-                        dest='config',
-                        action='store',
-                        default=defs['config'],
-                        help=_help)
-
-    _help = 'Regular expression for extracting conatiner number from ' \
-            'container name (default: %s)' % defs['container_name_regex']
-    parser.add_argument('-X', '--container-number-extractor',
-                        dest='container_name_regex',
-                        action='store',
-                        default=defs['container_name_regex'],
-                        help=_help)
-
-    _help = '<hostname>:<port> to consul agent (default: %s)' % defs['consul']
-    parser.add_argument('-C', '--consul',
-                        dest='consul',
-                        action='store',
-                        default=defs['consul'],
-                        help=_help)
-
-    _help = 'name of this adapter (default: %s)' % defs['name']
-    parser.add_argument('-na', '--name',
-                        dest='name',
-                        action='store',
-                        default=defs['name'],
-                        help=_help)
-
-    _help = 'vendor of this adapter (default: %s)' % defs['vendor']
-    parser.add_argument('-ven', '--vendor',
-                        dest='vendor',
-                        action='store',
-                        default=defs['vendor'],
-                        help=_help)
-
-    _help = 'supported device type of this adapter (default: %s)' % defs[
-        'device_type']
-    parser.add_argument('-dt', '--device_type',
-                        dest='device_type',
-                        action='store',
-                        default=defs['device_type'],
-                        help=_help)
-
-    _help = 'specifies whether the device type accepts bulk flow updates ' \
-            'adapter (default: %s)' % defs['accept_bulk_flow']
-    parser.add_argument('-abf', '--accept_bulk_flow',
-                        dest='accept_bulk_flow',
-                        action='store',
-                        default=defs['accept_bulk_flow'],
-                        help=_help)
-
-    _help = 'specifies whether the device type accepts add/remove flow ' \
-            '(default: %s)' % defs['accept_atomic_flow']
-    parser.add_argument('-aaf', '--accept_atomic_flow',
-                        dest='accept_atomic_flow',
-                        action='store',
-                        default=defs['accept_atomic_flow'],
-                        help=_help)
-
-    _help = '<hostname>:<port> to etcd server (default: %s)' % defs['etcd']
-    parser.add_argument('-e', '--etcd',
-                        dest='etcd',
-                        action='store',
-                        default=defs['etcd'],
-                        help=_help)
-
-    _help = ('unique string id of this container instance (default: %s)'
-             % defs['instance_id'])
-    parser.add_argument('-i', '--instance-id',
-                        dest='instance_id',
-                        action='store',
-                        default=defs['instance_id'],
-                        help=_help)
-
-    _help = 'ETH interface to recieve (default: %s)' % defs['interface']
-    parser.add_argument('-I', '--interface',
-                        dest='interface',
-                        action='store',
-                        default=defs['interface'],
-                        help=_help)
-
-    _help = 'omit startup banner log lines'
-    parser.add_argument('-n', '--no-banner',
-                        dest='no_banner',
-                        action='store_true',
-                        default=False,
-                        help=_help)
-
-    _help = 'do not emit periodic heartbeat log messages'
-    parser.add_argument('-N', '--no-heartbeat',
-                        dest='no_heartbeat',
-                        action='store_true',
-                        default=False,
-                        help=_help)
-
-    _help = "suppress debug and info logs"
-    parser.add_argument('-q', '--quiet',
-                        dest='quiet',
-                        action='count',
-                        help=_help)
-
-    _help = 'enable verbose logging'
-    parser.add_argument('-v', '--verbose',
-                        dest='verbose',
-                        action='count',
-                        help=_help)
-
-    _help = ('use docker container name as conatiner instance id'
-             ' (overrides -i/--instance-id option)')
-    parser.add_argument('--instance-id-is-container-name',
-                        dest='instance_id_is_container_name',
-                        action='store_true',
-                        default=False,
-                        help=_help)
-
-    _help = ('<hostname>:<port> of the kafka adapter broker (default: %s). ('
-             'If not '
-             'specified (None), the address from the config file is used'
-             % defs['kafka_adapter'])
-    parser.add_argument('-KA', '--kafka_adapter',
-                        dest='kafka_adapter',
-                        action='store',
-                        default=defs['kafka_adapter'],
-                        help=_help)
-
-    _help = ('<hostname>:<port> of the kafka cluster broker (default: %s). ('
-             'If not '
-             'specified (None), the address from the config file is used'
-             % defs['kafka_cluster'])
-    parser.add_argument('-KC', '--kafka_cluster',
-                        dest='kafka_cluster',
-                        action='store',
-                        default=defs['kafka_cluster'],
-                        help=_help)
-
-    _help = 'backend to use for config persitence'
-    parser.add_argument('-b', '--backend',
-                        default=defs['backend'],
-                        choices=['none', 'consul', 'etcd'],
-                        help=_help)
-
-    _help = 'topic of core on the kafka bus'
-    parser.add_argument('-ct', '--core_topic',
-                        dest='core_topic',
-                        action='store',
-                        default=defs['core_topic'],
-                        help=_help)
-
-    args = parser.parse_args()
-
-    # post-processing
-
-    if args.instance_id_is_container_name:
-        args.instance_id = get_my_containers_name()
-
-    return args
-
-
-def load_config(args):
-    path = args.config
-    if path.startswith('.'):
-        dir = os.path.dirname(os.path.abspath(__file__))
-        path = os.path.join(dir, path)
-    path = os.path.abspath(path)
-    with open(path) as fd:
-        config = yaml.load(fd)
-    return config
-
-
-def print_banner(log):
-    log.info(' ____                 _              ___  _   _ _   _    ')
-    log.info('|  _ \ ___  _ __  ___(_)_ __ ___    / _ \| \ | | | | |   ')
-    log.info('| |_) / _ \| \'_ \/ __| | \'_ ` _ \  | | | |  \| | | | | ')
-    log.info('|  __/ (_) | | | \__ \ | | | | | | | |_| | |\  | |_| |   ')
-    log.info('|_|   \___/|_| |_|___/_|_| |_| |_|  \___/|_| \_|\___/    ')
-    log.info('    _       _             _                            ')
-    log.info('   / \   __| | __ _ _ __ | |_ ___ _ __                 ')
-    log.info('  / _ \ / _` |/ _` | \'_ \| __/ _ \ \'__|              ')
-    log.info(' / ___ \ (_| | (_| | |_) | ||  __/ |                   ')
-    log.info('/_/   \_\__,_|\__,_| .__/ \__\___|_|                   ')
-    log.info('                   |_|                                 ')
-    log.info('(to stop: press Ctrl-C)')
-
-
-@implementer(IComponent)
-class Main(object):
-
-    def __init__(self):
-
-        self.args = args = parse_args()
-        self.config = load_config(args)
-
-        verbosity_adjust = (args.verbose or 0) - (args.quiet or 0)
-        self.log = setup_logging(self.config.get('logging', {}),
-                                 args.instance_id,
-                                 verbosity_adjust=verbosity_adjust)
-        self.log.info('container-number-extractor',
-                      regex=args.container_name_regex)
-
-        self.ponsim_olt_adapter_version = self.get_version()
-        self.log.info('Ponsim-ONU-Adapter-Version', version=
-        self.ponsim_olt_adapter_version)
-
-        if not args.no_banner:
-            print_banner(self.log)
-
-        self.adapter = None
-        # Create a unique instance id using the passed-in instance id and
-        # UTC timestamp
-        current_time = arrow.utcnow().timestamp
-        self.instance_id = self.args.instance_id + '_' + str(current_time)
-
-        self.core_topic = args.core_topic
-        self.listening_topic = args.name
-        self.startup_components()
-
-        if not args.no_heartbeat:
-            self.start_heartbeat()
-            self.start_kafka_cluster_heartbeat(self.instance_id)
-
-    def get_version(self):
-        path = defs['version_file']
-        if not path.startswith('/'):
-            dir = os.path.dirname(os.path.abspath(__file__))
-            path = os.path.join(dir, path)
-
-        path = os.path.abspath(path)
-        version_file = open(path, 'r')
-        v = version_file.read()
-
-        # Use Version to validate the version string - exception will be raised
-        # if the version is invalid
-        Version(v)
-
-        version_file.close()
-        return v
-
-    def start(self):
-        self.start_reactor()  # will not return except Keyboard interrupt
-
-    def stop(self):
-        pass
-
-    def get_args(self):
-        """Allow access to command line args"""
-        return self.args
-
-    def get_config(self):
-        """Allow access to content of config file"""
-        return self.config
-
-    def _get_adapter_config(self):
-        cfg = AdapterConfig()
-        return cfg
-
-    @inlineCallbacks
-    def startup_components(self):
-        try:
-            self.log.info('starting-internal-components',
-                          consul=self.args.consul,
-                          etcd=self.args.etcd)
-
-            registry.register('main', self)
-
-            # Update the logger to output the vcore id.
-            self.log = update_logging(instance_id=self.instance_id,
-                                      vcore_id=None)
-
-            yield registry.register(
-                'kafka_cluster_proxy',
-                KafkaProxy(
-                    self.args.consul,
-                    self.args.kafka_cluster,
-                    config=self.config.get('kafka-cluster-proxy', {})
-                )
-            ).start()
-
-            config = self._get_adapter_config()
-
-            self.core_proxy = CoreProxy(
-                kafka_proxy=None,
-                default_core_topic=self.core_topic,
-                my_listening_topic=self.listening_topic)
-
-            self.adapter_proxy = AdapterProxy(
-                kafka_proxy=None,
-                core_topic=self.core_topic,
-                my_listening_topic=self.listening_topic)
-
-            self.adapter = PonSimOnuAdapter(
-                core_proxy=self.core_proxy, adapter_proxy=self.adapter_proxy,
-                config=config)
-            ponsim_request_handler = AdapterRequestFacade(
-                adapter=self.adapter, core_proxy=self.core_proxy)
-
-            yield registry.register(
-                'kafka_adapter_proxy',
-                IKafkaMessagingProxy(
-                    kafka_host_port=self.args.kafka_adapter,
-                    # TODO: Add KV Store object reference
-                    kv_store=self.args.backend,
-                    default_topic=self.args.name,
-                    group_id_prefix=self.args.instance_id,
-                    target_cls=ponsim_request_handler
-                )
-            ).start()
-
-            self.core_proxy.kafka_proxy = get_messaging_proxy()
-            self.adapter_proxy.kafka_proxy = get_messaging_proxy()
-
-            # retry for ever
-            res = yield self._register_with_core(-1)
-
-            self.log.info('started-internal-services')
-
-        except Exception as e:
-            self.log.exception('Failure-to-start-all-components', e=e)
-
-    @inlineCallbacks
-    def shutdown_components(self):
-        """Execute before the reactor is shut down"""
-        self.log.info('exiting-on-keyboard-interrupt')
-        for component in reversed(registry.iterate()):
-            yield component.stop()
-
-        import threading
-        self.log.info('THREADS:')
-        main_thread = threading.current_thread()
-        for t in threading.enumerate():
-            if t is main_thread:
-                continue
-            if not t.isDaemon():
-                continue
-            self.log.info('joining thread {} {}'.format(
-                t.getName(), "daemon" if t.isDaemon() else "not-daemon"))
-            t.join()
-
-    def start_reactor(self):
-        from twisted.internet import reactor
-        reactor.callWhenRunning(
-            lambda: self.log.info('twisted-reactor-started'))
-        reactor.addSystemEventTrigger('before', 'shutdown',
-                                      self.shutdown_components)
-        reactor.run()
-
-    @inlineCallbacks
-    def _register_with_core(self, retries):
-        while 1:
-            try:
-                resp = yield self.core_proxy.register(
-                    self.adapter.adapter_descriptor(),
-                    self.adapter.device_types())
-                if resp:
-                    self.log.info('registered-with-core',
-                                  coreId=resp.instance_id)
-
-                returnValue(resp)
-            except TimeOutError as e:
-                self.log.warn("timeout-when-registering-with-core", e=e)
-                if retries == 0:
-                    self.log.exception("no-more-retries", e=e)
-                    raise
-                else:
-                    retries = retries if retries < 0 else retries - 1
-                    yield asleep(defs['retry_interval'])
-            except Exception as e:
-                self.log.exception("failed-registration", e=e)
-                raise
-
-    def start_heartbeat(self):
-
-        t0 = time.time()
-        t0s = time.ctime(t0)
-
-        def heartbeat():
-            self.log.debug(status='up', since=t0s, uptime=time.time() - t0)
-
-        lc = LoopingCall(heartbeat)
-        lc.start(10)
-
-    # Temporary function to send a heartbeat message to the external kafka
-    # broker
-    def start_kafka_cluster_heartbeat(self, instance_id):
-        # For heartbeat we will send a message to a specific "voltha-heartbeat"
-        #  topic.  The message is a protocol buf
-        # message
-        message = dict(
-            type='heartbeat',
-            adapter=self.args.name,
-            instance=instance_id,
-            ip=get_my_primary_local_ipv4()
-        )
-        topic = defs['heartbeat_topic']
-
-        def send_msg(start_time):
-            try:
-                kafka_cluster_proxy = get_kafka_proxy()
-                if kafka_cluster_proxy and not kafka_cluster_proxy.is_faulty():
-                    # self.log.debug('kafka-proxy-available')
-                    message['ts'] = arrow.utcnow().timestamp
-                    message['uptime'] = time.time() - start_time
-                    # self.log.debug('start-kafka-heartbeat')
-                    kafka_cluster_proxy.send_message(topic, dumps(message))
-                else:
-                    self.log.error('kafka-proxy-unavailable')
-            except Exception, e:
-                self.log.exception('failed-sending-message-heartbeat', e=e)
-
-        try:
-            t0 = time.time()
-            lc = LoopingCall(send_msg, t0)
-            lc.start(10)
-        except Exception, e:
-            self.log.exception('failed-kafka-heartbeat', e=e)
-
-
-if __name__ == '__main__':
-    Main().start()
diff --git a/python/adapters/ponsim_onu/ponsim_onu.py b/python/adapters/ponsim_onu/ponsim_onu.py
deleted file mode 100644
index 0987147..0000000
--- a/python/adapters/ponsim_onu/ponsim_onu.py
+++ /dev/null
@@ -1,514 +0,0 @@
-#
-# Copyright 2017 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-"""
-Represents an ONU device
-"""
-
-from uuid import uuid4
-
-import arrow
-import structlog
-from google.protobuf.json_format import MessageToDict
-from google.protobuf.message import Message
-from simplejson import dumps
-from twisted.internet.defer import DeferredQueue, inlineCallbacks, \
-    returnValue, Deferred
-from twisted.internet.task import LoopingCall
-
-from pyvoltha.common.utils.asleep import asleep
-from pyvoltha.adapters.iadapter import OnuAdapter
-from pyvoltha.adapters.kafka.kafka_proxy import get_kafka_proxy
-from voltha_protos.common_pb2 import OperStatus, ConnectStatus, AdminState
-from voltha_protos.inter_container_pb2 import PortCapability, \
-    InterAdapterMessageType, InterAdapterResponseBody
-from voltha_protos.device_pb2 import Port, PmConfig, PmConfigs
-from voltha_protos.events_pb2 import KpiEvent, KpiEventType, MetricValuePairs
-from voltha_protos.logical_device_pb2 import LogicalPort
-from voltha_protos.openflow_13_pb2 import OFPPS_LIVE, OFPPF_FIBER, \
-    OFPPF_1GB_FD
-from voltha_protos.openflow_13_pb2 import ofp_port
-from voltha_protos.ponsim_pb2 import FlowTable, PonSimMetricsRequest, PonSimMetrics
-
-log = structlog.get_logger()
-
-
-def mac_str_to_tuple(mac):
-    return tuple(int(d, 16) for d in mac.split(':'))
-
-
-class AdapterPmMetrics:
-    def __init__(self, device):
-        self.pm_names = {'tx_64_pkts', 'tx_65_127_pkts', 'tx_128_255_pkts',
-                         'tx_256_511_pkts', 'tx_512_1023_pkts',
-                         'tx_1024_1518_pkts', 'tx_1519_9k_pkts',
-                         'rx_64_pkts', 'rx_65_127_pkts',
-                         'rx_128_255_pkts', 'rx_256_511_pkts',
-                         'rx_512_1023_pkts', 'rx_1024_1518_pkts',
-                         'rx_1519_9k_pkts'}
-        self.device = device
-        self.id = device.id
-        self.name = 'ponsim_onu'
-        self.default_freq = 150
-        self.grouped = False
-        self.freq_override = False
-        self.pm_metrics = None
-        self.pon_metrics_config = dict()
-        self.uni_metrics_config = dict()
-        self.lc = None
-        for m in self.pm_names:
-            self.pon_metrics_config[m] = PmConfig(name=m,
-                                                  type=PmConfig.COUNTER,
-                                                  enabled=True)
-            self.uni_metrics_config[m] = PmConfig(name=m,
-                                                  type=PmConfig.COUNTER,
-                                                  enabled=True)
-
-    def update(self, pm_config):
-        if self.default_freq != pm_config.default_freq:
-            # Update the callback to the new frequency.
-            self.default_freq = pm_config.default_freq
-            self.lc.stop()
-            self.lc.start(interval=self.default_freq / 10)
-        for m in pm_config.metrics:
-            self.pon_metrics_config[m.name].enabled = m.enabled
-            self.uni_metrics_config[m.name].enabled = m.enabled
-
-    def make_proto(self):
-        pm_config = PmConfigs(
-            id=self.id,
-            default_freq=self.default_freq,
-            grouped=False,
-            freq_override=False)
-        for m in sorted(self.pon_metrics_config):
-            pm = self.pon_metrics_config[m]  # Either will do they're the same
-            pm_config.metrics.extend([PmConfig(name=pm.name,
-                                               type=pm.type,
-                                               enabled=pm.enabled)])
-        return pm_config
-
-    def extract_metrics(self, stats):
-        rtrn_port_metrics = dict()
-        rtrn_port_metrics['pon'] = self.extract_pon_metrics(stats)
-        rtrn_port_metrics['uni'] = self.extract_uni_metrics(stats)
-        return rtrn_port_metrics
-
-    def extract_pon_metrics(self, stats):
-        rtrn_pon_metrics = dict()
-        for m in stats.metrics:
-            if m.port_name == "pon":
-                for p in m.packets:
-                    if self.pon_metrics_config[p.name].enabled:
-                        rtrn_pon_metrics[p.name] = p.value
-                return rtrn_pon_metrics
-
-    def extract_uni_metrics(self, stats):
-        rtrn_pon_metrics = dict()
-        for m in stats.metrics:
-            if m.port_name == "uni":
-                for p in m.packets:
-                    if self.pon_metrics_config[p.name].enabled:
-                        rtrn_pon_metrics[p.name] = p.value
-                return rtrn_pon_metrics
-
-    def start_collector(self, callback):
-        log.info("starting-pm-collection", device_name=self.name,
-                 device_id=self.device.id)
-        prefix = 'voltha.{}.{}'.format(self.name, self.device.id)
-        self.lc = LoopingCall(callback, self.device.id, prefix)
-        self.lc.start(interval=self.default_freq / 10)
-
-    def stop_collector(self):
-        log.info("stopping-pm-collection", device_name=self.name,
-                 device_id=self.device.id)
-        self.lc.stop()
-
-
-class PonSimOnuAdapter(OnuAdapter):
-    def __init__(self, core_proxy, adapter_proxy, config):
-        # DeviceType of ONU should be same as VENDOR ID of ONU Serial Number
-        # as specified by standard
-        # requires for identifying correct adapter or ranged ONU
-        super(PonSimOnuAdapter, self).__init__(core_proxy=core_proxy,
-                                               adapter_proxy=adapter_proxy,
-                                               config=config,
-                                               device_handler_class=PonSimOnuHandler,
-                                               name='ponsim_onu',
-                                               vendor='Voltha project',
-                                               version='0.4',
-                                               device_type='ponsim_onu',
-                                               vendor_id='PSMO',
-                                               accepts_bulk_flow_update=True,
-                                               accepts_add_remove_flow_updates=False)
-
-
-class PonSimOnuHandler(object):
-    def __init__(self, adapter, device_id):
-        self.adapter = adapter
-        self.core_proxy = adapter.core_proxy
-        self.adapter_proxy = adapter.adapter_proxy
-        self.device_id = device_id
-        self.device_parent_id = None
-        self.log = structlog.get_logger(device_id=device_id)
-        self.incoming_messages = DeferredQueue()
-        self.inter_adapter_message_deferred_map = {}
-        self.proxy_address = None
-        # reference of uni_port is required when re-enabling the device if
-        # it was disabled previously
-        self.uni_port = None
-        self.pon_port = None
-
-    def _to_string(self, unicode_str):
-        if unicode_str is not None:
-            if type(unicode_str) == unicode:
-                return unicode_str.encode('ascii', 'ignore')
-            else:
-                return unicode_str
-        else:
-            return ""
-
-    def receive_message(self, msg):
-        trns_id = self._to_string(msg.header.id)
-        if trns_id in self.inter_adapter_message_deferred_map:
-            self.inter_adapter_message_deferred_map[trns_id].callback(msg)
-            # self.incoming_messages.put(msg)
-
-    @inlineCallbacks
-    def activate(self, device):
-        self.log.info('activating')
-
-        self.device_parent_id = device.parent_id
-        self.proxy_address = device.proxy_address
-
-        # populate device info
-        device.root = False
-        device.vendor = 'ponsim'
-        device.model = 'n/a'
-        device.serial_number = device.serial_number
-        device.mac_address = "AA:BB:CC:DD:E0:00"
-        yield self.core_proxy.device_update(device)
-
-        # Now set the initial PM configuration for this device
-        self.pm_metrics = AdapterPmMetrics(device)
-        pm_config = self.pm_metrics.make_proto()
-        log.info("initial-pm-config", pm_config=pm_config)
-        yield self.core_proxy.device_pm_config_update(pm_config, init=True)
-
-        # Use the channel Id, assigned by the parent device to me, as the port number
-        uni_port = 2
-        if device.proxy_address is not None:
-            if device.proxy_address.channel_id != 0:
-                uni_port =  device.proxy_address.channel_id
-
-        # register physical ports
-        self.uni_port = Port(
-            port_no=uni_port,
-            label="uni-" + str(uni_port),
-            type=Port.ETHERNET_UNI,
-            admin_state=AdminState.ENABLED,
-            oper_status=OperStatus.ACTIVE
-        )
-        self.pon_port = Port(
-            port_no=1,
-            label='pon-1',
-            type=Port.PON_ONU,
-            admin_state=AdminState.ENABLED,
-            oper_status=OperStatus.ACTIVE,
-            peers=[
-                Port.PeerPort(
-                    device_id=device.parent_id,
-                    port_no=device.parent_port_no
-                )
-            ]
-        )
-        yield self.core_proxy.port_created(device.id, self.uni_port)
-        yield self.core_proxy.port_created(device.id, self.pon_port)
-
-        yield self.core_proxy.device_state_update(device.id,
-                                                  connect_status=ConnectStatus.REACHABLE,
-                                                  oper_status=OperStatus.ACTIVE)
-
-        # Start collecting stats from the device after a brief pause
-        self.start_kpi_collection(device.id)
-
-    # TODO: Return only port specific info
-    def get_ofp_port_info(self, device, port_no):
-        # Since the adapter created the device port then it has the reference
-        #  of the port to
-        # return the capability.   TODO:  Do a lookup on the UNI port number
-        # and return the
-        # appropriate attributes
-        self.log.info('get_ofp_port_info', port_no=port_no, device_id=device.id)
-        cap = OFPPF_1GB_FD | OFPPF_FIBER
-        return PortCapability(
-            port=LogicalPort(
-                ofp_port=ofp_port(
-                    hw_addr=mac_str_to_tuple('AA:BB:CC:DD:E0:%02x' % port_no),
-                    config=0,
-                    state=OFPPS_LIVE,
-                    curr=cap,
-                    advertised=cap,
-                    peer=cap,
-                    curr_speed=OFPPF_1GB_FD,
-                    max_speed=OFPPF_1GB_FD
-                ),
-                device_id=device.id,
-                device_port_no=port_no
-            )
-        )
-
-    @inlineCallbacks
-    def _get_uni_port(self):
-        ports = yield self.core_proxy.get_ports(self.device_id,
-                                                Port.ETHERNET_UNI)
-        returnValue(ports)
-
-    @inlineCallbacks
-    def _get_pon_port(self):
-        ports = yield self.core_proxy.get_ports(self.device_id, Port.PON_ONU)
-        returnValue(ports)
-
-    def reconcile(self, device):
-        self.log.info('reconciling-ONU-device-starts')
-        # TODO: complete code
-
-    @inlineCallbacks
-    def update_flow_table(self, flows):
-        trnsId = None
-        try:
-            self.log.info('update_flow_table', flows=flows)
-            # we need to proxy through the OLT to get to the ONU
-
-            fb = FlowTable(
-                port=self.proxy_address.channel_id,
-                flows=flows
-            )
-
-            # Create a deferred to wait for the result as well as a transid
-            wait_for_result = Deferred()
-            trnsId = uuid4().hex
-            self.inter_adapter_message_deferred_map[
-                self._to_string(trnsId)] = wait_for_result
-
-            # Sends the request via proxy and wait for an ACK
-            yield self.adapter_proxy.send_inter_adapter_message(
-                msg=fb,
-                type=InterAdapterMessageType.FLOW_REQUEST,
-                from_adapter=self.adapter.name,
-                to_adapter=self.proxy_address.device_type,
-                to_device_id=self.device_id,
-                proxy_device_id=self.proxy_address.device_id,
-                message_id=trnsId
-            )
-            # Wait for the full response from the proxied adapter
-            res = yield wait_for_result
-            if res.header.type == InterAdapterMessageType.FLOW_RESPONSE:
-                body = InterAdapterResponseBody()
-                res.body.Unpack(body)
-                self.log.info('response-received', result=body.status)
-        except Exception as e:
-            self.log.exception("update-flow-error", e=e)
-        finally:
-            if trnsId in self.inter_adapter_message_deferred_map:
-                del self.inter_adapter_message_deferred_map[trnsId]
-
-    def process_inter_adapter_message(self, msg):
-        # We expect only responses on the ONU side
-        self.log.info('process-inter-adapter-message', msg=msg)
-        self.receive_message(msg)
-
-    def remove_from_flow_table(self, flows):
-        self.log.debug('remove-from-flow-table', flows=flows)
-        # TODO: Update PONSIM code to accept incremental flow changes.
-        # Once completed, the accepts_add_remove_flow_updates for this
-        # device type can be set to True
-
-    def add_to_flow_table(self, flows):
-        self.log.debug('add-to-flow-table', flows=flows)
-        # TODO: Update PONSIM code to accept incremental flow changes
-        # Once completed, the accepts_add_remove_flow_updates for this
-        # device type can be set to True
-
-    @inlineCallbacks
-    def reboot(self):
-        self.log.info('rebooting', device_id=self.device_id)
-
-        # Update the connect status to UNREACHABLE
-        yield self.core_proxy.device_state_update(self.device_id,
-                                                  connect_status=ConnectStatus.UNREACHABLE)
-
-        # Sleep 10 secs, simulating a reboot
-        # TODO: send alert and clear alert after the reboot
-        yield asleep(10)
-
-        # Change the connection status back to REACHABLE.  With a
-        # real ONU the connection state must be the actual state
-        yield self.core_proxy.device_state_update(self.device_id,
-                                                  connect_status=ConnectStatus.REACHABLE)
-
-        self.log.info('rebooted', device_id=self.device_id)
-
-    def self_test_device(self, device):
-        """
-        This is called to Self a device based on a NBI call.
-        :param device: A Voltha.Device object.
-        :return: Will return result of self test
-        """
-        log.info('self-test-device', device=device.id)
-        raise NotImplementedError()
-
-    @inlineCallbacks
-    def disable(self):
-        self.log.info('disabling', device_id=self.device_id)
-
-        # Update the device operational status to UNKNOWN
-        yield self.core_proxy.device_state_update(self.device_id,
-                                                  oper_status=OperStatus.UNKNOWN,
-                                                  connect_status=ConnectStatus.UNREACHABLE)
-
-        self.stop_kpi_collection()
-
-        # TODO:
-        # 1) Remove all flows from the device
-        # 2) Remove the device from ponsim
-        self.log.info('disabled', device_id=self.device_id)
-
-    @inlineCallbacks
-    def reenable(self):
-        self.log.info('re-enabling', device_id=self.device_id)
-        try:
-
-            # Refresh the port reference - we only use one port for now
-            ports = yield self._get_uni_port()
-            self.log.info('re-enabling-uni-ports', ports=ports)
-            if ports.items:
-                self.uni_port = ports.items[0]
-
-            ports = yield self._get_pon_port()
-            self.log.info('re-enabling-pon-ports', ports=ports)
-            if ports.items:
-                self.pon_port = ports.items[0]
-
-            # Update the state of the UNI port
-            yield self.core_proxy.port_state_update(self.device_id,
-                                                    port_type=Port.ETHERNET_UNI,
-                                                    port_no=self.uni_port.port_no,
-                                                    oper_status=OperStatus.ACTIVE)
-
-            # Update the state of the PON port
-            yield self.core_proxy.port_state_update(self.device_id,
-                                                    port_type=Port.PON_ONU,
-                                                    port_no=self.pon_port.port_no,
-                                                    oper_status=OperStatus.ACTIVE)
-
-            yield self.core_proxy.device_state_update(self.device_id,
-                                                      oper_status=OperStatus.ACTIVE,
-                                                      connect_status=ConnectStatus.REACHABLE)
-
-            self.start_kpi_collection(self.device_id)
-
-            self.log.info('re-enabled', device_id=self.device_id)
-        except Exception, e:
-            self.log.exception('error-reenabling', e=e)
-
-    def delete(self):
-        self.log.info('deleting', device_id=self.device_id)
-
-        # TODO:
-        # 1) Remove all flows from the device
-        # 2) Remove the device from ponsim
-
-        self.log.info('deleted', device_id=self.device_id)
-
-    def start_kpi_collection(self, device_id):
-        kafka_cluster_proxy = get_kafka_proxy()
-
-        @inlineCallbacks
-        def _collect(device_id, prefix):
-            try:
-                self.log.debug("pm-collection-interval")
-                # Proxy a message to ponsim_olt. The OLT will then query the ONU
-                # for statistics. The reply will
-                # arrive proxied back to us in self.receive_message().
-                msg = PonSimMetricsRequest(port=self.proxy_address.channel_id)
-
-                # Create a deferred to wait for the result as well as a transid
-                wait_for_result = Deferred()
-                trnsId = uuid4().hex
-                self.inter_adapter_message_deferred_map[
-                    self._to_string(trnsId)] = wait_for_result
-
-                # Sends the request via proxy and wait for an ACK
-                yield self.adapter_proxy.send_inter_adapter_message(
-                    msg=msg,
-                    type=InterAdapterMessageType.METRICS_REQUEST,
-                    from_adapter=self.adapter.name,
-                    to_adapter=self.proxy_address.device_type,
-                    to_device_id=self.device_id,
-                    proxy_device_id=self.proxy_address.device_id,
-                    message_id=trnsId
-                )
-                # Wait for the full response from the proxied adapter
-                res = yield wait_for_result
-                # Remove the transaction from the transaction map
-                del self.inter_adapter_message_deferred_map[self._to_string(trnsId)]
-
-                # Message is a reply to an ONU statistics request. Push it out to
-                #  Kafka via adapter.submit_kpis().
-                if res.header.type == InterAdapterMessageType.METRICS_RESPONSE:
-                    msg = InterAdapterResponseBody()
-                    res.body.Unpack(msg)
-                    self.log.debug('metrics-response-received', result=msg.status)
-                    if self.pm_metrics:
-                        self.log.debug('Handling incoming ONU metrics')
-                        response = PonSimMetrics()
-                        msg.body.Unpack(response)
-                        port_metrics = self.pm_metrics.extract_metrics(response)
-                        try:
-                            ts = arrow.utcnow().timestamp
-                            kpi_event = KpiEvent(
-                                type=KpiEventType.slice,
-                                ts=ts,
-                                prefixes={
-                                    # OLT NNI port
-                                    prefix + '.uni': MetricValuePairs(
-                                        metrics=port_metrics['uni']),
-                                    # OLT PON port
-                                    prefix + '.pon': MetricValuePairs(
-                                        metrics=port_metrics['pon'])
-                                }
-                            )
-
-                            self.log.debug(
-                                'Submitting KPI for incoming ONU mnetrics')
-
-                            # Step 3: submit directly to the kafka bus
-                            if kafka_cluster_proxy:
-                                if isinstance(kpi_event, Message):
-                                    kpi_event = dumps(
-                                        MessageToDict(kpi_event, True, True))
-                                kafka_cluster_proxy.send_message("voltha.kpis",
-                                                                 kpi_event)
-
-                        except Exception as e:
-                            log.exception('failed-to-submit-kpis', e=e)
-            except Exception as e:
-                log.exception('failed-to-collect-metrics', e=e)
-
-        self.pm_metrics.start_collector(_collect)
-
-    def stop_kpi_collection(self):
-        self.pm_metrics.stop_collector()
diff --git a/python/adapters/ponsim_onu/ponsim_onu.yml b/python/adapters/ponsim_onu/ponsim_onu.yml
deleted file mode 100644
index aa9d43c..0000000
--- a/python/adapters/ponsim_onu/ponsim_onu.yml
+++ /dev/null
@@ -1,67 +0,0 @@
----
-# Copyright 2018 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-logging:
-    version: 1
-
-    formatters:
-      brief:
-        format: '%(message)s'
-      default:
-        format: '%(asctime)s.%(msecs)03d %(levelname)-8s %(threadName)s %(module)s.%(funcName)s %(message)s'
-        datefmt: '%Y%m%dT%H%M%S'
-
-    handlers:
-        console:
-            class : logging.StreamHandler
-            level: DEBUG
-            formatter: default
-            stream: ext://sys.stdout
-        localRotatingFile:
-            class: logging.handlers.RotatingFileHandler
-            filename: ponsim_onu.log
-            formatter: default
-            maxBytes: 2097152
-            backupCount: 10
-            level: DEBUG
-        null:
-            class: logging.NullHandler
-
-    loggers:
-        amqp:
-            handlers: [null]
-            propagate: False
-        conf:
-            propagate: False
-        '': # root logger
-            handlers: [console, localRotatingFile]
-            level: DEBUG # this can be bumped up/down by -q and -v command line
-                        # options
-            propagate: False
-
-
-kafka-cluster-proxy:
-    event_bus_publisher:
-        topic_mappings:
-            'model-change-events':
-                kafka_topic: 'voltha.events'
-                filters:     [null]
-            'alarms':
-                kafka_topic: 'voltha.alarms'
-                filters:     [null]
-            'kpis':
-                kafka_topic: 'voltha.kpis'
-                filters:     [null]
-
