# Path: networking_odl/common/client.py
# LOG = log.getLogger(__name__)
# class OpenDaylightRestClient(object):
# class OpenDaylightRestClientGlobal(object):
#     def _check_opt(url):
#     def create_client(cls, url=None):
#     def __init__(self, url, username, password, timeout):
#     def get_resource(self, resource_type, resource_id):
#     def get(self, urlpath='', data=None):
#     def request(self, method, urlpath='', data=None):
#     def sendjson(self, method, urlpath, obj):
#     def _check_response(self, response):
#     def __init__(self):
#     def get_client(self):
# 
# Path: networking_odl/common/odl_features.py
# LOG = log.getLogger(__name__)
# OPERATIONAL_PORT_STATUS = 'operational-port-status'
# EMPTY_FEATURES = {}
# def init():
# def has(feature):
# def get_config(feature):
# def deinit():
# def _load_features(json):
# def _fetch_features():
# 
# Path: networking_odl/common/utils.py
# def try_del(d, keys):
# def make_url_object(object_type):
# def neutronify(name):
# def get_odl_url(path=''):
# 
# Path: networking_odl/common/websocket_client.py
# LOG = log.getLogger(__name__)
# ODL_OPERATIONAL_DATASTORE = "OPERATIONAL"
# ODL_CONFIGURATION_DATASTORE = "CONFIGURATION"
# ODL_NOTIFICATION_SCOPE_BASE = "BASE"
# ODL_NOTIFICATION_SCOPE_ONE = "ONE"
# ODL_NOTIFICATION_SCOPE_SUBTREE = "SUBTREE"
# ODL_WEBSOCKET_DISCONNECTED = "ODL_WEBSOCKET_DISCONNECTED"
# ODL_WEBSOCKET_CONNECTING = "ODL_WEBSOCKET_CONNECTING"
# ODL_WEBSOCKET_CONNECTED = "ODL_WEBSOCKET_CONNECTED"
#     NOTIFICATION_TAG = 'notification'
#     DC_NOTIFICATION_TAG = 'data-changed-notification'
#     DC_EVENT_TAG = 'data-change-event'
#     OPERATION_DELETE = 'deleted'
#     OPERATION_CREATE = 'created'
#     OPERATION_UPDATE = 'updated'
# class OpenDaylightWebsocketClient(object):
# class EventDataParser(object):
#     def __init__(self, odl_rest_client, path, datastore, scope, leaf_node_only,
#                  packet_handler, timeout, status_cb=None):
#     def odl_create_websocket(cls, odl_url, path, datastore, scope,
#                              packet_handler, status_cb=None,
#                              leaf_node_only=False):
#     def start_odl_websocket_thread(self):
#     def set_exit_flag(self, value=True):
#     def run_websocket_thread(self, exit_after_run=False):
#     def _set_websocket_status(self, status):
#     def _subscribe_websocket(self):
#     def _socket_create_connection(self, stream_url):
#     def _connect_ws(self):
#     def _close_ws(self, ws):
#     def __init__(self, item):
#     def get_item(cls, payload):
#     def get_fields(self):
#     def get_path(self):
#     def get_data(self):
#     def get_operation(self):
#     def extract_field(text, key):


import threading
from neutron_lib.callbacks import resources
from neutron_lib import constants as n_const
from neutron_lib import context
from neutron_lib.plugins import directory
from neutron_lib import worker
from oslo_log import log
from neutron.db import provisioning_blocks
from networking_odl.common import client as odl_client
from networking_odl.common import odl_features
from networking_odl.common import utils
from networking_odl.common import websocket_client as odl_ws_client
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.





LOG = log.getLogger(__name__)


class OdlPortStatusUpdate(worker.BaseWorker):
    """Class to register and handle port status update"""
    PORT_PATH = "restconf/operational/neutron:neutron/ports/port"

    def __init__(self):
        super(OdlPortStatusUpdate, self).__init__()
        self.odl_websocket_client = None

    def start(self):
        super(OdlPortStatusUpdate, self).start()
        LOG.debug('OdlPortStatusUpdate worker running')

# Path: networking_odl/common/client.py
# LOG = log.getLogger(__name__)
# class OpenDaylightRestClient(object):
# class OpenDaylightRestClientGlobal(object):
#     def _check_opt(url):
#     def create_client(cls, url=None):
#     def __init__(self, url, username, password, timeout):
#     def get_resource(self, resource_type, resource_id):
#     def get(self, urlpath='', data=None):
#     def request(self, method, urlpath='', data=None):
#     def sendjson(self, method, urlpath, obj):
#     def _check_response(self, response):
#     def __init__(self):
#     def get_client(self):
# 
# Path: networking_odl/common/odl_features.py
# LOG = log.getLogger(__name__)
# OPERATIONAL_PORT_STATUS = 'operational-port-status'
# EMPTY_FEATURES = {}
# def init():
# def has(feature):
# def get_config(feature):
# def deinit():
# def _load_features(json):
# def _fetch_features():
# 
# Path: networking_odl/common/utils.py
# def try_del(d, keys):
# def make_url_object(object_type):
# def neutronify(name):
# def get_odl_url(path=''):
# 
# Path: networking_odl/common/websocket_client.py
# LOG = log.getLogger(__name__)
# ODL_OPERATIONAL_DATASTORE = "OPERATIONAL"
# ODL_CONFIGURATION_DATASTORE = "CONFIGURATION"
# ODL_NOTIFICATION_SCOPE_BASE = "BASE"
# ODL_NOTIFICATION_SCOPE_ONE = "ONE"
# ODL_NOTIFICATION_SCOPE_SUBTREE = "SUBTREE"
# ODL_WEBSOCKET_DISCONNECTED = "ODL_WEBSOCKET_DISCONNECTED"
# ODL_WEBSOCKET_CONNECTING = "ODL_WEBSOCKET_CONNECTING"
# ODL_WEBSOCKET_CONNECTED = "ODL_WEBSOCKET_CONNECTED"
#     NOTIFICATION_TAG = 'notification'
#     DC_NOTIFICATION_TAG = 'data-changed-notification'
#     DC_EVENT_TAG = 'data-change-event'
#     OPERATION_DELETE = 'deleted'
#     OPERATION_CREATE = 'created'
#     OPERATION_UPDATE = 'updated'
# class OpenDaylightWebsocketClient(object):
# class EventDataParser(object):
#     def __init__(self, odl_rest_client, path, datastore, scope, leaf_node_only,
#                  packet_handler, timeout, status_cb=None):
#     def odl_create_websocket(cls, odl_url, path, datastore, scope,
#                              packet_handler, status_cb=None,
#                              leaf_node_only=False):
#     def start_odl_websocket_thread(self):
#     def set_exit_flag(self, value=True):
#     def run_websocket_thread(self, exit_after_run=False):
#     def _set_websocket_status(self, status):
#     def _subscribe_websocket(self):
#     def _socket_create_connection(self, stream_url):
#     def _connect_ws(self):
#     def _close_ws(self, ws):
#     def __init__(self, item):
#     def get_item(cls, payload):
#     def get_fields(self):
#     def get_path(self):
#     def get_data(self):
#     def get_operation(self):
#     def extract_field(text, key):


# Path: networking_odl/ml2/port_status_update.py
import threading
from neutron_lib.callbacks import resources
from neutron_lib import constants as n_const
from neutron_lib import context
from neutron_lib.plugins import directory
from neutron_lib import worker
from oslo_log import log
from neutron.db import provisioning_blocks
from networking_odl.common import client as odl_client
from networking_odl.common import odl_features
from networking_odl.common import utils
from networking_odl.common import websocket_client as odl_ws_client

#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.





LOG = log.getLogger(__name__)


class OdlPortStatusUpdate(worker.BaseWorker):
    """Class to register and handle port status update"""
    PORT_PATH = "restconf/operational/neutron:neutron/ports/port"

    def __init__(self):
        super(OdlPortStatusUpdate, self).__init__()
        self.odl_websocket_client = None

    def start(self):
        super(OdlPortStatusUpdate, self).start()
        LOG.debug('OdlPortStatusUpdate worker running')

        if odl_features.has(odl_features.OPERATIONAL_PORT_STATUS):