Getting access to config in actions

Tom Barber tom at spicule.co.uk
Thu Dec 29 17:09:06 UTC 2016


Thanks Marco I'll have a prod about.

On Thu, Dec 29, 2016 at 5:02 PM, Marco Ceppi <marco.ceppi at canonical.com>
wrote:

> Hook config is only setable by operators, not charms. If the-crawldb-uri
> isn't a config option specified in config.yaml and a value set by running
> `juju set` then the behavior you described is expected.
>
> I'd recommend using the kv module in charm-helpers to persist data between
> hooks. https://pythonhosted.org/charmhelpers/api/charmhelpers.
> core.unitdata.html
>
> Marco
>
> On Thu, Dec 29, 2016, 11:54 AM Tom Barber <tom at spicule.co.uk> wrote:
>
>> Not sure if I'm doing something stupid here or not.
>>
>> If I do something like:
>>
>>
>>   config = hookenv.config()
>>   config['the-crawldb-uri'] = 'test'# s.connection_string()
>>   print("set value is" +config['the-crawldb-uri'])
>>
>> in a reactive python charm, I want to be able to access that value in an
>> action which I seem to fail miserably on, anything config related like:
>>
>> juju run --unit sparkler/0 "config-get the-crawldb-uri"
>> or
>>
>> from charmhelpers.core import hookenv
>>
>> def main():
>>     out = hookenv.config('the-crawldb-uri')
>>     print("uri is "+out)
>>
>> just returns null. But if I manually set a value in a config block and
>> call config-get it returns the value, so how do I bridge that gap?
>>
>>
>>
>>
>> --
>> Tom Barber
>> CTO Spicule LTD
>> tom at spicule.co.uk
>>
>> http://spicule.co.uk
>>
>> @spiculeim <http://twitter.com/spiculeim>
>>
>> Schedule a meeting with me <http://meetme.so/spicule>
>>
>> GB: +44(0)5603641316 <+44%2056%200364%201316>
>> US: +18448141689 <(844)%20814-1689>
>>
>>
>> --
>> Juju mailing list
>> Juju at lists.ubuntu.com
>> Modify settings or unsubscribe at: https://lists.ubuntu.com/
>> mailman/listinfo/juju
>>
>


-- 
Tom Barber
CTO Spicule LTD
tom at spicule.co.uk

http://spicule.co.uk

@spiculeim <http://twitter.com/spiculeim>

Schedule a meeting with me <http://meetme.so/spicule>

GB: +44(0)5603641316
US: +18448141689
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju/attachments/20161229/5c8b272c/attachment.html>


More information about the Juju mailing list