OsmoCtrl cleanup: get_var(), set_var(), get_trap()

CTRL interface interaction was mostly inherited from the first legacy
implementation of osmo-gsm-tester, and it was a pain to look at from the
start. Now, while I'm close to the topic, I want this to improve:

Properly match a GET_REPLY/SET_REPLY to a sent GET/SET by the message
ID.

Completely drop the do_get() and do_set(), which were not useful for
correct handling of the CTRL request and response messaging. The API to
use by callers is set_var(), get_var()/get_int_var() and get_trap().
These call the internal _sendrecv() (or for TRAP only _recv())
functions. Make it so that tese work both on an already connected
OsmoCtrl, as well as one that needs to establish a (short) connection,
so that both are trivially possible:

    # one CTRL connection stays open
    with OsmoCtrl(...) as ctrl:
  	ctrl.get_var('var1')
  	ctrl.get_var('var2')
  	ctrl.get_var('var3')

and

  # get_var() opens a connection, does the GET and closes again
  OsmoCtrl(...).get_var('var1')

Do away with doubling the instances OsmoCtrl and e.g. OsmoBscCtrl.
Rather make OsmoBscCtrl a child class of OsmoCtrl, which means that we
no longer have bsc.ctrl().ctrl(), just bsc.ctrl().

Have VERB_* constants instead of dup'd strings.

Apply to / simplify all callers of OsmoCtrl.

Some of these changes are similar to recently added OsmoVty.

Change-Id: Id561e5a55d8057a997a8ec9e7fa6f94840194df1
diff --git a/src/osmo_gsm_tester/obj/msc_osmo.py b/src/osmo_gsm_tester/obj/msc_osmo.py
index 67e1d31..5a7c0ba 100644
--- a/src/osmo_gsm_tester/obj/msc_osmo.py
+++ b/src/osmo_gsm_tester/obj/msc_osmo.py
@@ -157,29 +157,12 @@
         return not self.process.terminated()
 
 
-class OsmoMscCtrl(log.Origin):
-    PORT = 4255
-    SUBSCR_LIST_ACTIVE_VAR = 'subscriber-list-active-v1'
-
-    def __init__(self, msc):
+class OsmoMscCtrl(osmo_ctrl.OsmoCtrl):
+    def __init__(self, msc, port=4255):
         self.msc = msc
-        super().__init__(log.C_BUS, 'CTRL(%s:%d)' % (self.msc.addr(), self.PORT))
-
-    def ctrl(self):
-        return osmo_ctrl.OsmoCtrl(self.msc.addr(), self.PORT)
+        super().__init__(self.msc.addr(), port)
 
     def subscriber_list_active(self):
-        aslist_str = ""
-        with self.ctrl() as ctrl:
-            ctrl.do_get(self.SUBSCR_LIST_ACTIVE_VAR)
-            # This is legacy code from the old osmo-gsm-tester.
-            # looks like this doesn't work for long data.
-            data = ctrl.receive()
-            while (len(data) > 0):
-                (answer, data) = ctrl.remove_ipa_ctrl_header(data)
-                answer_str = answer.decode('utf-8')
-                answer_str = answer_str.replace('\n', ' ')
-                aslist_str = answer_str
-            return aslist_str
+        return self.get_var('subscriber-list-active-v1').replace('\n', ' ')
 
 # vim: expandtab tabstop=4 shiftwidth=4