Hello guys,
So, i'm defining:
DBURL "mysql://user:password@dbhost/dbname"
and later on...
modparam("sqlops","sqlcon","cb=>"DBURL)
and this fails miserably..
What do do on this case?
Thanks all!
Regards,
David Villasmil email: david.villasmil.work@gmail.com phone: +34669448337
No,
DBURL translates into
"mysql://user:admin@dbuser/dbname"
so in sqlops:
modparam("sqlops","sqlcon","cb=>DBURL")
translates into:
modparam("sqlops","sqlcon","cb=>"mysql://user:admin@dbuser/dbname"")
that works great on
modparam("domain", "db_url", DBURL)
because it translates into:
modparam("domain", "db_url", "mysql://user:admin@dbuser/dbname")
But not on the sqlops case
Regards,
David Villasmil email: david.villasmil.work@gmail.com phone: +34669448337
On Sat, May 11, 2019 at 12:32 AM Sergiu Pojoga pojogas@gmail.com wrote:
yes that works.
My problem is not with sqlops.
My problem is with the DEFINE.
If I define:
#!define DBURL "mysql://user:password@localhost/dbname"
and later:
modparam("domain", "db_url", DBURL)
and then:
modparam("sqlops","sqlcon","cb=>mysql://user:password@localhost/dbname")
Everything works properly.
My problem is how to use that DEFINE on ALL instances where i need to use it. i.e.
#!define DBURL "mysql://user:password@localhost/dbname" modparam("domain", "db_url", DBURL) modparam("sqlops","sqlcon","cb=>mysql://user:password@localhost/dbname")
works, but;
#!define DBURL © modparam("domain", "db_url", DBURL) modparam("sqlops","sqlcon","cb=>DBURL")
does NOT, since DBURL translates "mysql://user:password@localhost/dbname" (quotes included)
so modparam("sqlops","sqlcon","cb=>DBURL") translates into modparam("sqlops","sqlcon","cb=>"mysql://user:password@localhost/dbname"")
and that, of course, fails.
Regards,
David Villasmil email: david.villasmil.work@gmail.com phone: +34669448337
On Sat, May 11, 2019 at 12:59 AM Sergiu Pojoga pojogas@gmail.com wrote:
Hello,
use:
#!substdef "!DBURL!mysql://user:password@localhost/dbname!"
The define is replacing only standalone tokens, not inside string values, like you have for sqlcon.
More docs about should be in core cookbook from wiki.
Cheers, Daniel
On 11.05.19 02:05, David Villasmil wrote:
Thanks Daniel;
The thing is I’m trying to implement password-less starts (no hardcoded password)
So I’m querying the password on start from aws ssm and injecting it as a define, like.
Kamailio -f kamailio.cfg -A “DBURL `script-than-returns-MySQL-dburl-lambda.sh`“
Is it possible to do substrdef from the command line?
Better yet, do you have a different. Approach to doing this?
David
On Sat, 11 May 2019 at 07:12, Daniel-Constantin Mierla miconda@gmail.com wrote:
Regards,
David Villasmil email: david.villasmil.work@gmail.com phone: +34669448337
Try first something like:
modparam("sqlops","sqlcon","cb=>" DBURL )
If doesn't work, then:
modparam("sqlops","sqlcon", CBDBURL)
and have -A twice, one for DBURL and another one for CBDBURL.
The latest dev version (iirc) has the option to evaluate variables in the defines, so you can use there the environment pseudo-variables.
Cheers, Daniel
On 11.05.19 11:56, David Villasmil wrote:
This fails miserably:
kamailio -f /etc/kamailio/kamailio.cfg -E \ -A "DBURL mysql://admin:mypass@db.mydomaincom/kamailio" \ -A "CBDBURL cb=>mysql://admin:mypass@db.mydomaincom/kamailio" \ -A "ASGDBURL asg=>mysql://admin:mypass@db.mydomaincom/kamailio" -DDDD
modparam("sqlops","sqlcon", CBDBURL)
As does this:
kamailio -f /etc/kamailio/kamailio.cfg -E \ -A "DBURL mysql://admin:mypass@db.mydomaincom/kamailio" \ -A "CBDBURL cb=>mysql://admin:mypass@db.mydomaincom/kamailio" \ -A "ASGDBURL asg=>mysql://admin:mypass@db.mydomaincom/kamailio" -DDDD
cfg
modparam("sqlops","sqlcon", "CBDBURL") ... $var(rows)=$sqlrows(cb);
When running:
0(27514) CRITICAL: <core> [core/cfg.y:3424]: yyerror_at(): parse error in config file /etc/kamailio/kamailio.cfg, line 1200, column 13-24: Can't get from cache: $sqlrows(cb)
while hardcoded does work...
Don't really know where to go from here... It seems sqlops just doesn't take a define as the dburl source
Regards,
David Villasmil email: david.villasmil.work@gmail.com phone: +34669448337
On Sun, May 12, 2019 at 8:38 AM Daniel-Constantin Mierla miconda@gmail.com wrote:
Finally figured out how to do it:
cfg: modparam("acc", "db_url", DBURL) ... modparam("sqlops","sqlcon", CBDBURL) ... modparam("sqlops","sqlcon", ASGDBURL)
and startup:
kamailio -f /etc/kamailio/kamailio.cfg -E \ -A 'DBURL="mysql://admin:mypass@db.mydomaincom/kamailio"' \ -A "CBDBURL="cb=>admin:mypass@db.mydomaincom/kamailio"" \ -A 'ASGDBURL="asg=>admin:mypass@db.mydomaincom/kamailio"' -DDDD 2>&1
Now let's try and put that on the startup systemd script.
Hello,
for convenience, I added command line parameters to set #!subst, #!substdef and #!substdefs expressions - details about them in the wiki:
* https://www.kamailio.org/wiki/cookbooks/devel/core#subst
It is only in master branch, being new features, but maybe you can test and report if they work fine. It should be like:
kamailio --subst="%DBURL%mysql://admin:mypass@db.mydomaincom/kamailio%" ...
And in kamailio.cfg:
modparam("acc", "db_url", "DBURL") ... modparam("sqlops","sqlcon", "cb=>DBURL") ... modparam("sqlops","sqlcon", "asg=>DBURL")
Cheers, Daniel
On 12.05.19 23:51, David Villasmil wrote:
Awesome, thanks! That’s perfect!
On Tue, 14 May 2019 at 16:14, Daniel-Constantin Mierla miconda@gmail.com wrote:
Regards,
David Villasmil email: david.villasmil.work@gmail.com phone: +34669448337
Hello,
I added some examples in master branch about using -A to define tokens with values, I noticed it was not properly documented, it has to be like:
-A TOKEN
-A 'TOKEN=val'
-A 'TOKEN="val"'
a matter of needing the value to be surrounded by the double quotes or not.
Cheers, Daniel
On 12.05.19 22:32, David Villasmil wrote: