VOL-2171: Lock ont-g/ani only after all pptp/veip are locked

Also yield so the locking activity finishes before the
callbacks are called, so the MDS increment for the set
can be recorded in openomci

Ultimately this all prevents the MDS from getting out of sync
when disable is called and the locking is *halfway* done and
the omci state machine is prematurely stopped, causing some set responses
to be missed. which cases the MDS increment to be off.

This then later causes during an enable a forced reconcile when
we dont need it.  Having the MDS properly match speeds up re-enable.

Also remove custom get_mds_task thats not been used in quite some time.

Change-Id: Idfe295a61e8fc2810e8f0c956c5997c7a26b32ab
diff --git a/python/adapters/brcm_openomci_onu/omci/brcm_get_mds_task.py b/python/adapters/brcm_openomci_onu/omci/brcm_get_mds_task.py
deleted file mode 100644
index 16a8783..0000000
--- a/python/adapters/brcm_openomci_onu/omci/brcm_get_mds_task.py
+++ /dev/null
@@ -1,61 +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.
-
-import structlog
-from pyvoltha.adapters.extensions.omci.tasks.get_mds_task import GetMdsTask
-
-
-class BrcmGetMdsTask(GetMdsTask):
-    """
-    OpenOMCI Get MIB Data Sync value task - Broadcom ONU
-
-    On successful completion, this task will call the 'callback' method of the
-    deferred returned by the start method and return the value of the MIB
-    Data Sync attribute of the ONT Data ME
-    """
-    name = "BRCM: Get MDS Task"
-
-    def __init__(self, omci_agent, device_id):
-        """
-        Class initialization
-
-        :param omci_agent: (OmciAdapterAgent) OMCI Adapter agent
-        :param device_id: (str) ONU Device ID
-        """
-        self.log = structlog.get_logger(device_id=device_id)
-        self.log.debug('function-entry')
-
-        super(BrcmGetMdsTask, self).__init__(omci_agent, device_id)
-
-        self.name = BrcmGetMdsTask.name
-        self._device = omci_agent.get_device(device_id)
-        self._omci_managed = False      # TODO: Look up capabilities/model number/check handler
-
-    def perform_get_mds(self):
-        """
-        Get the 'mib_data_sync' attribute of the ONU
-        """
-        self.log.debug('function-entry')
-        self.log.info('perform-get-mds')
-
-        if self._omci_managed:
-            return super(BrcmGetMdsTask, self).perform_get_mds()
-
-        # Non-OMCI managed BRCM ONUs always return 0 for MDS, use the MIB
-        # sync value and depend on an accelerated mib resync to do the
-        # proper comparison
-
-        self.deferred.callback(self._device.mib_synchronizer.mib_data_sync)
-
diff --git a/python/adapters/brcm_openomci_onu/omci/brcm_uni_lock_task.py b/python/adapters/brcm_openomci_onu/omci/brcm_uni_lock_task.py
index f062075..cbe22fa 100644
--- a/python/adapters/brcm_openomci_onu/omci/brcm_uni_lock_task.py
+++ b/python/adapters/brcm_openomci_onu/omci/brcm_uni_lock_task.py
@@ -84,6 +84,21 @@
             state = 1 if self._lock else 0
 
             # lock the whole ont and all the pptp.  some onu dont causing odd behavior.
+            pptp_list = sorted(self._config.pptp_entities) if self._config.pptp_entities else []
+            veip_list = sorted(self._config.veip_entities) if self._config.veip_entities else []
+
+            for entity_id in pptp_list:
+                pptp_value = self._config.pptp_entities[entity_id]
+                msg = PptpEthernetUniFrame(entity_id,
+                                           attributes=dict(administrative_state=state))
+                yield self._send_uni_lock_msg(entity_id, pptp_value, msg)
+
+            for entity_id in veip_list:
+                veip_value = self._config.veip_entities[entity_id]
+                msg = VeipUniFrame(entity_id,
+                                           attributes=dict(administrative_state=state))
+                yield self._send_uni_lock_msg(entity_id, veip_value, msg)
+
             msg = OntGFrame(attributes={'administrative_state': state})
             frame = msg.set()
             self.log.debug('openomci-msg', omci_msg=msg)
@@ -99,21 +114,6 @@
             else:
                 self.log.warn('cannot-set-lock-ontg', lock=self._lock)
 
-            pptp_list = sorted(self._config.pptp_entities) if self._config.pptp_entities else []
-            veip_list = sorted(self._config.veip_entities) if self._config.veip_entities else []
-
-            for entity_id in pptp_list:
-                pptp_value = self._config.pptp_entities[entity_id]
-                msg = PptpEthernetUniFrame(entity_id,
-                                           attributes=dict(administrative_state=state))
-                self._send_uni_lock_msg(entity_id, pptp_value, msg)
-
-            for entity_id in veip_list:
-                veip_value = self._config.veip_entities[entity_id]
-                msg = VeipUniFrame(entity_id,
-                                           attributes=dict(administrative_state=state))
-                self._send_uni_lock_msg(entity_id, veip_value, msg)
-
             self.deferred.callback(self)
 
         except Exception as e:
diff --git a/python/requirements.txt b/python/requirements.txt
index 9f0114a..cee78b5 100644
--- a/python/requirements.txt
+++ b/python/requirements.txt
@@ -1,2 +1,2 @@
 voltha-protos==1.0.0
-pyvoltha==2.2.4
+pyvoltha==2.2.5