How to set state in @hook code block?

fengxia fxia1 at lenovo.com
Thu Jul 20 02:58:13 UTC 2017


Hi Juju,

I think I read at some point in the official document that you can't set 
state from hook.

However, this is what I'm trying to achieve: in @hook('config-changed'), 
I will pass in a file path as a config value. Files are part of the 
charm so they are installed in 
/var/lib/juju/agents/unit-mycharm/myfiles/ on the unit node. But when 
@hook('config-changed') is triggered, my code to "open('/path/file')" 
actually complains "file not found". This makes me wonder that hook is 
not visible of the charm directory?

So I'm thinking this can be worked around if I set_state("mystate") from 
hook. But doing so didn't trigger @when("mystate").

What's the right way to do this then?

-- 
Feng xia
Engineer
Lenovo USA

Phone: 5088011794
fxia1 at lenovo.com
  	
Lenovo.com
Twitter | Facebook | Instagram | Blogs | Forums




More information about the Juju mailing list