blob: 731f5a7fa4c1fc5186ffe3635ec271f82321348a [file] [log] [blame]
Pau Espin Pedrol52ad3a62018-03-08 17:50:14 +01001# 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
20import os
21import pprint
22import tempfile
23from abc import ABCMeta, abstractmethod
Pau Espin Pedrol9a4631c2018-03-28 19:17:34 +020024from . import log, config, util, template, process, pcu_osmo
Pau Espin Pedrol52ad3a62018-03-08 17:50:14 +010025
26class 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
Pau Espin Pedrole5194622018-05-07 13:36:58 +020035 defaults_cfg_name = None
Pau Espin Pedrol52ad3a62018-03-08 17:50:14 +010036
37##############
38# PROTECTED
39##############
Pau Espin Pedrole5194622018-05-07 13:36:58 +020040 def __init__(self, suite_run, conf, name, defaults_cfg_name):
Pau Espin Pedrol52ad3a62018-03-08 17:50:14 +010041 super().__init__(log.C_RUN, name)
42 self.suite_run = suite_run
43 self.conf = conf
Pau Espin Pedrole5194622018-05-07 13:36:58 +020044 self.defaults_cfg_name = defaults_cfg_name
Pau Espin Pedrole6999122018-05-08 14:38:24 +020045
46 def conf_for_bsc_prepare(self):
47 values = config.get_defaults('bsc_bts')
48 config.overlay(values, config.get_defaults(self.defaults_cfg_name))
49 if self.lac is not None:
50 config.overlay(values, { 'location_area_code': self.lac })
51 if self.rac is not None:
52 config.overlay(values, { 'routing_area_code': self.rac })
53 if self.cellid is not None:
54 config.overlay(values, { 'cell_identity': self.cellid })
55 if self.bvci is not None:
56 config.overlay(values, { 'bvci': self.bvci })
57 config.overlay(values, self.conf)
58
59 sgsn_conf = {} if self.sgsn is None else self.sgsn.conf_for_client()
60 config.overlay(values, sgsn_conf)
61 return values
62
Pau Espin Pedrol52ad3a62018-03-08 17:50:14 +010063########################
64# PUBLIC - INTERNAL API
65########################
66 @abstractmethod
67 def conf_for_bsc(self):
68 'Used by bsc objects to get path to socket.'
69 pass
70
71 def remote_addr(self):
72 return self.conf.get('addr')
73
74 def cleanup(self):
75 'Nothing to do by default. Subclass can override if required.'
76 pass
77
78###################
79# PUBLIC (test API included)
80###################
81 @abstractmethod
82 def start(self):
83 'Starts BTS proccess and sets self.proc_bts with an object of Process interface'
84 pass
85
86 @abstractmethod
87 def ready_for_pcu(self):
88 'True if the BTS is prepared to have a PCU connected, false otherwise'
89 pass
90
91 @abstractmethod
92 def pcu(self):
93 'Get the Pcu object associated with the BTS'
94 pass
95
96 def set_bsc(self, bsc):
97 self.bsc = bsc
98
99 def set_sgsn(self, sgsn):
100 self.sgsn = sgsn
101
102 def set_lac(self, lac):
103 self.lac = lac
104
105 def set_rac(self, rac):
106 self.rac = rac
107
108 def set_cellid(self, cellid):
109 self.cellid = cellid
110
111 def set_bvci(self, bvci):
112 self.bvci = bvci
113
114# vim: expandtab tabstop=4 shiftwidth=4