blob: 6aa17e70e9cc4aa7c5deabc9ba15a89a2b5da67a [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
Pau Espin Pedrolc04528c2020-04-01 13:55:51 +020036 def configure(self, config_specifics_li):
Pau Espin Pedrolda2e31f2020-03-31 13:45:01 +020037 values = dict(epc=config.get_defaults('epc'))
Pau Espin Pedrolc04528c2020-04-01 13:55:51 +020038 for config_specifics in config_specifics_li:
39 config.overlay(values, dict(epc=config.get_defaults(config_specifics)))
Pau Espin Pedrolda2e31f2020-03-31 13:45:01 +020040 config.overlay(values, dict(epc=self.suite_run.config().get('epc', {})))
Pau Espin Pedrolc04528c2020-04-01 13:55:51 +020041 for config_specifics in config_specifics_li:
42 config.overlay(values, dict(epc=self.suite_run.config().get(config_specifics, {})))
Pau Espin Pedrolda2e31f2020-03-31 13:45:01 +020043 config.overlay(values, dict(epc={'run_addr': self.addr()}))
44 return values
45
46########################
47# PUBLIC - INTERNAL API
48########################
49 def cleanup(self):
50 'Nothing to do by default. Subclass can override if required.'
51 pass
52
53###################
54# PUBLIC (test API included)
55###################
56 @abstractmethod
57 def start(self, epc):
58 'Starts ENB, it will connect to "epc"'
59 pass
60
61 @abstractmethod
62 def subscriber_add(self, modem, msisdn=None, algo_str=None):
63 pass
64
65 @abstractmethod
66 def enb_is_connected(self, enb):
67 pass
68
69 @abstractmethod
70 def running(self):
71 pass
72
73 @abstractmethod
74 def tun_addr(self):
75 pass
76
77 def addr(self):
78 return self._addr
79
80 def run_node(self):
81 return self._run_node
82
83# vim: expandtab tabstop=4 shiftwidth=4