Re: Getting access to config in actions

2016-12-29 Thread Tom Barber
Thanks Marco I'll have a prod about.

On Thu, Dec 29, 2016 at 5:02 PM, Marco Ceppi 
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  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
>> t...@spicule.co.uk
>>
>> http://spicule.co.uk
>>
>> @spiculeim 
>>
>> Schedule a meeting with me 
>>
>> GB: +44(0)5603641316 <+44%2056%200364%201316>
>> US: +18448141689 <(844)%20814-1689>
>>
>>
>> --
>> Juju mailing list
>> Juju@lists.ubuntu.com
>> Modify settings or unsubscribe at: https://lists.ubuntu.com/
>> mailman/listinfo/juju
>>
>


-- 
Tom Barber
CTO Spicule LTD
t...@spicule.co.uk

http://spicule.co.uk

@spiculeim 

Schedule a meeting with me 

GB: +44(0)5603641316
US: +18448141689
-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju


Re: Getting access to config in actions

2016-12-29 Thread Marco Ceppi
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  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
> t...@spicule.co.uk
>
> http://spicule.co.uk
>
> @spiculeim 
>
> Schedule a meeting with me 
>
> GB: +44(0)5603641316
> US: +18448141689
>
>
> --
> Juju mailing list
> Juju@lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/juju
>
-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju


Getting access to config in actions

2016-12-29 Thread Tom Barber
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
t...@spicule.co.uk

http://spicule.co.uk

@spiculeim 

Schedule a meeting with me 

GB: +44(0)5603641316
US: +18448141689
-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju