blob: da8302cb35426482108f0159167ca7c398749fcf [file] [log] [blame]
Pau Espin Pedrolda2e31f2020-03-31 13:45:01 +02001# osmo_gsm_tester: base classes to share code among EPC subclasses.
2#
3# Copyright (C) 2020 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
20from abc import ABCMeta, abstractmethod
21from . import log, config
22
23
24class EPC(log.Origin, metaclass=ABCMeta):
25
26##############
27# PROTECTED
28##############
29 def __init__(self, suite_run, run_node, name):
30 super().__init__(log.C_RUN, '%s' % name)
31 self._addr = run_node.run_addr()
32 self.set_name('%s_%s' % (name, self._addr))
33 self.suite_run = suite_run
34 self._run_node = run_node
35
36 def configure(self, default_specifics):
37 values = dict(epc=config.get_defaults('epc'))
38 config.overlay(values, dict(epc=config.get_defaults(default_specifics)))
39 config.overlay(values, dict(epc=self.suite_run.config().get('epc', {})))
40 config.overlay(values, dict(epc={'run_addr': self.addr()}))
41 return values
42
43########################
44# PUBLIC - INTERNAL API
45########################
46 def cleanup(self):
47 'Nothing to do by default. Subclass can override if required.'
48 pass
49
50###################
51# PUBLIC (test API included)
52###################
53 @abstractmethod
54 def start(self, epc):
55 'Starts ENB, it will connect to "epc"'
56 pass
57
58 @abstractmethod
59 def subscriber_add(self, modem, msisdn=None, algo_str=None):
60 pass
61
62 @abstractmethod
63 def enb_is_connected(self, enb):
64 pass
65
66 @abstractmethod
67 def running(self):
68 pass
69
70 @abstractmethod
71 def tun_addr(self):
72 pass
73
74 def addr(self):
75 return self._addr
76
77 def run_node(self):
78 return self._run_node
79
80# vim: expandtab tabstop=4 shiftwidth=4