[asterisk-dev] [PATCH] dahdi-tools: add command 'compare' to dahdi_span_types

Tzafrir Cohen tzafrir.cohen at xorcom.com
Tue Jun 13 08:13:37 CDT 2017


Applying /etc/dahdi/span_types.conf with 'dahdi_span_types set' requires
the spans not to be assigned. In my application I needed to apply a
configuration that may include changes to span_types.conf (but normally
doesn't). If I do need to apply changes, I need to unassign the spans
before doing so, and I prefer not to do so in the common case.

It seems that the simplest way to check for that is to add a test in
dahdi_span_types itself. I thus added a separate subcommand: 'compare':
If there are no changes to apply, it outputs nothing and returns 0. If
there are changes, it outputs the changes, and returns 5.

> cat /etc/dahdi/span-types.conf
usb:X1062931 [1]:T1
usb:X1062931 [2]:E1
usb:X1062931 [3]:E1
usb:X1062931 [4]:E1
usb:INT10588 [1]:E1
usb:INT10588 [2]:E1
usb:INT10588 [3]:T1
usb:INT10588 [4]:E1
usb:INT09157 [1]:E1
usb:INT09157 [2]:E1
usb:INT09157 [3]:E1
usb:INT09157 [4]:T1

> dahdi_span_types list
# PRI span types (E1/T1/J1)
1:E1       [usb:INT10588]       @usb-0000:00:14.0-1.4          /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.4/xbus-00/astribanks:xbus-00
2:E1       [usb:INT10588]       @usb-0000:00:14.0-1.4          /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.4/xbus-00/astribanks:xbus-00
3:E1       [usb:INT10588]       @usb-0000:00:14.0-1.4          /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.4/xbus-00/astribanks:xbus-00
4:E1       [usb:INT10588]       @usb-0000:00:14.0-1.4          /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.4/xbus-00/astribanks:xbus-00
1:E1       [usb:INT09157]       @usb-0000:00:14.0-1.2          /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/xbus-01/astribanks:xbus-01
2:E1       [usb:INT09157]       @usb-0000:00:14.0-1.2          /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/xbus-01/astribanks:xbus-01
3:T1       [usb:INT09157]       @usb-0000:00:14.0-1.2          /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/xbus-01/astribanks:xbus-01
4:T1       [usb:INT09157]       @usb-0000:00:14.0-1.2          /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/xbus-01/astribanks:xbus-01
1:E1       [usb:X1062931]       @usb-0000:00:14.0-1.1.4        /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.1/1-1.1.4/xbus-05/astribanks:xbus-05
2:E1       [usb:X1062931]       @usb-0000:00:14.0-1.1.4        /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.1/1-1.1.4/xbus-05/astribanks:xbus-05
3:E1       [usb:X1062931]       @usb-0000:00:14.0-1.1.4        /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.1/1-1.1.4/xbus-05/astribanks:xbus-05
4:E1       [usb:X1062931]       @usb-0000:00:14.0-1.1.4        /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.1/1-1.1.4/xbus-05/astribanks:xbus-05

> dahdi_span_types compare 
# Device           Unit  Config Active
astribanks:xbus-00 3     T1     E1
astribanks:xbus-01 3     E1     T1
astribanks:xbus-05 1     T1     E1

> echo $?
5





More information about the asterisk-dev mailing list