Pau Espin Pedrol | 52ad3a6 | 2018-03-08 17:50:14 +0100 | [diff] [blame] | 1 | # osmo_gsm_tester: base classes to share code among BTS subclasses. |
| 2 | # |
| 3 | # Copyright (C) 2018 by sysmocom - s.f.m.c. GmbH |
| 4 | # |
| 5 | # Author: Pau Espin Pedrol <pespin@sysmocom.de> |
| 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as |
| 9 | # published by the Free Software Foundation, either version 3 of the |
| 10 | # License, or (at your option) any later version. |
| 11 | # |
| 12 | # This program is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | |
| 20 | import os |
| 21 | import pprint |
| 22 | import tempfile |
| 23 | from abc import ABCMeta, abstractmethod |
Pau Espin Pedrol | 9a4631c | 2018-03-28 19:17:34 +0200 | [diff] [blame] | 24 | from . import log, config, util, template, process, pcu_osmo |
Pau Espin Pedrol | 52ad3a6 | 2018-03-08 17:50:14 +0100 | [diff] [blame] | 25 | |
| 26 | class Bts(log.Origin, metaclass=ABCMeta): |
| 27 | suite_run = None |
| 28 | conf = None |
| 29 | bsc = None |
| 30 | sgsn = None |
| 31 | lac = None |
| 32 | rac = None |
| 33 | cellid = None |
| 34 | bvci = None |
| 35 | |
| 36 | ############## |
| 37 | # PROTECTED |
| 38 | ############## |
| 39 | def __init__(self, suite_run, conf, name): |
| 40 | super().__init__(log.C_RUN, name) |
| 41 | self.suite_run = suite_run |
| 42 | self.conf = conf |
| 43 | |
| 44 | ######################## |
| 45 | # PUBLIC - INTERNAL API |
| 46 | ######################## |
| 47 | @abstractmethod |
| 48 | def conf_for_bsc(self): |
| 49 | 'Used by bsc objects to get path to socket.' |
| 50 | pass |
| 51 | |
| 52 | def remote_addr(self): |
| 53 | return self.conf.get('addr') |
| 54 | |
| 55 | def cleanup(self): |
| 56 | 'Nothing to do by default. Subclass can override if required.' |
| 57 | pass |
| 58 | |
| 59 | ################### |
| 60 | # PUBLIC (test API included) |
| 61 | ################### |
| 62 | @abstractmethod |
| 63 | def start(self): |
| 64 | 'Starts BTS proccess and sets self.proc_bts with an object of Process interface' |
| 65 | pass |
| 66 | |
| 67 | @abstractmethod |
| 68 | def ready_for_pcu(self): |
| 69 | 'True if the BTS is prepared to have a PCU connected, false otherwise' |
| 70 | pass |
| 71 | |
| 72 | @abstractmethod |
| 73 | def pcu(self): |
| 74 | 'Get the Pcu object associated with the BTS' |
| 75 | pass |
| 76 | |
| 77 | def set_bsc(self, bsc): |
| 78 | self.bsc = bsc |
| 79 | |
| 80 | def set_sgsn(self, sgsn): |
| 81 | self.sgsn = sgsn |
| 82 | |
| 83 | def set_lac(self, lac): |
| 84 | self.lac = lac |
| 85 | |
| 86 | def set_rac(self, rac): |
| 87 | self.rac = rac |
| 88 | |
| 89 | def set_cellid(self, cellid): |
| 90 | self.cellid = cellid |
| 91 | |
| 92 | def set_bvci(self, bvci): |
| 93 | self.bvci = bvci |
| 94 | |
| 95 | # vim: expandtab tabstop=4 shiftwidth=4 |