Passing regexps from SQL to unlang
Hello, I need to translate calling-station-id to E.164. NAS can send these numbers in several formats, for example number +74951234567 can come as 1234567, 04951234567 or 0074951234567. I think about adding a field in nas table and specify several regexps with delimiter. Can I fetch this field, parse it to several regexps and use them in unlang as regexps?
Maxim S. Denisov wrote:
I need to translate calling-station-id to E.164. NAS can send these numbers in several formats, for example number +74951234567 can come as 1234567, 04951234567 or 0074951234567. I think about adding a field in nas table and specify several regexps with delimiter. Can I fetch this field, parse it to several regexps and use them in unlang as regexps?
Not really. And it's probably not a good idea, either. Databases are for storing bulk data, not policies. This is the kind of thing you'd do in unlang. Just write 5-6 rules with regexes. They should catch the weird formats, and standardize them. Then, insert the standardized form into the database. Alan DeKok.
Hello Mr. DeKok, Thank you for your reply. There are many NASes in many regions and translation rules for them are different, I wanted make translation configuration using my ERP interface. Using files for this I will have to manage NAS configuration in two places and have a huge policy.conf. Regards, Maxim Denisov 18.02.2013, в 19:53, Alan DeKok <aland@deployingradius.com> написал(а):
Not really. And it's probably not a good idea, either. Databases are for storing bulk data, not policies.
This is the kind of thing you'd do in unlang. Just write 5-6 rules with regexes. They should catch the weird formats, and standardize them. Then, insert the standardized form into the database.
Maxim S. Denisov wrote:
Thank you for your reply. There are many NASes in many regions and translation rules for them are different, I wanted make translation configuration using my ERP interface. Using files for this I will have to manage NAS configuration in two places and have a huge policy.conf.
Well... the server can't use regex's from SQL. What you can do instead is to have a script which reads SQL, and writes a local policy.conf file. It's not perfect, but it will work. Alan DeKok.
participants (2)
-
Alan DeKok -
Maxim S. Denisov