summaryrefslogtreecommitdiff
path: root/2019/osmodevcon2019-osmo_config_merge/osmodevcon2019-osmo_config_merge.adoc
blob: ccee19cda30150184b44785c873fe1b81717e11e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
osmo-config-merge
=================
:author:	Harald Welte <laforge@gnumonks.org>
:copyright:	2019 by Harald Welte (License: CC-BY-SA)
:backend:	slidy
:max-width:	45em


== Problem statement

* in automatic testing, we have tons of copies of config files
* config file syntax breaks every so often during development
* manually updating all copies is error-prone and time consuming
* in many cases, a given test only wants to modify very few settings compared to default/example config

== So why not simply apply a  diff?

* the way how unified / context sensitive diff works doesn't match well 
* context above/below the to-be-changed/inserted line breaks as example config evolves
* vty actually does have structure: Its hierarchy. 

== `osmo-config-merge`

* allows to add "diffs" to osmocom VTY-style config files
* exploits the hierarchical nature to simply add lines to a given node in the tree
* lines are always appended to the end of node, so last incarnation of any given command will override any
  earlier incarnations

----
Usage: osmo-config-merge <config-file> <config-patch>...<config-patch> [--debug]
----

== Patch Format

* patch format simply follows normal VTY syntax
* full path of VTY nodes must be specified

----
network
 bts 0
  trx 0
   max-power-red 12
----

== Example usage

----
$ osmo-config-merge osmo-bsc.cfg foo.diff > patched.cfg
----

renders

----
$ diff -u osmo-bsc.cfg patched.cfg
--- osmo-bsc.cfg        2019-01-19 21:30:49.215940012 +0100
+++ patched.cfg   2019-04-25 12:29:48.163401121 +0200
@@ -71,6 +71,7 @@
    timeslot 7
     phys_chan_config TCH/F
     hopping enabled 0
+   max-power-red 12
 msc 0
  no bsc-welcome-text
  no bsc-msc-lost-text
----


== Demo


== EOF

End of File
personal git repositories of Harald Welte. Your mileage may vary