/srv/irclogs.ubuntu.com/2014/08/12/#juju.txt

=== Ursinha is now known as Ursinha-afk
=== Ursinha-afk is now known as Ursinha
=== menn0_ is now known as menn0
=== uru_ is now known as urulama
=== uru_ is now known as urulama
=== CyberJacob|Away is now known as CyberJacob
=== dosaboy_ is now known as dosaboy-alt
=== CyberJacob is now known as CyberJacob|Away
=== ming is now known as Guest79564
=== hloeung_ is now known as hloeung
=== jog_ is now known as jog
=== Ursinha is now known as Ursinha-afk
=== Ursinha-afk is now known as Ursinha
gnuoyjamespage, your thoughts on https://code.launchpad.net/~gnuoy/charms/trusty/nova-cloud-controller/disable-services-until-db-ready/+merge/230495 would be greatly appreciated if/when you have a moment14:48
=== roadmr is now known as roadmr_afk
=== urulama is now known as urulama-afk
=== urulama-afk is now known as urulama
=== roadmr_afk is now known as roadmr
=== urulama is now known as uru__
jrwrenWhat is the right way to use charmhelpers.core.hookenv.relation_get ?  I do not like that it is outputting errors.20:43
marcoceppijrwren: what errors are you getting?20:43
jrwrenno relation id specified20:44
marcoceppijrwren: is this being called out of band of a relation call?20:45
marcoceppiof a relation hook*20:45
marcoceppialternatively, just supply the current JUJU_RELATION_ID20:45
marcoceppifrom os.environ20:45
marcoceppijrwren: give me a min to open the code, the docs are light on this one20:47
jrwrenyes, out of band. I should look it up.20:47
marcoceppijrwren: docs are here, FYI: http://pythonhosted.org//charmhelpers/api/charmhelpers.core.html#charmhelpers.core.hookenv.relation_get20:47
marcoceppijrwren: in that case you need to provide the JUJU_RELATION_ID and the unit you wish to query this information20:47
marcoceppiduring a relation hook, both JUJU_RELATION_ID and JUJU_REMOTE_UNIT are environment variables set in the hook environment20:47
marcoceppijrwren: hum, the docs are out of date with the function signature20:49
marcoceppiyou pass unit and relation_id as parameters20:49
marcoceppielation_get(attribute=None, unit=None, rid=None)20:49
marcoceppirelation_get(attribute=None, unit=None, rid=None)20:49
marcoceppitvansteenburgh: can we get the docs re-generated?20:50
jrwrenmarcoceppi: where are the format of rid and unit documented?20:50
marcoceppijrwren: the format are the values of JUJU_RELATION_ID and JUJU_REMOTE_UNIT respectively20:51
marcoceppiremote unit being in the format of "service/#"20:51
marcoceppirelation id is typically "text:#"20:51
marcoceppiyou can query them using relation_id20:51
marcoceppiyou can query them using relation_ids*20:51
jrwrenI didn't have much like with any of that when I was debugging the hooks. I'll try again.20:52
marcoceppijrwren: they're only set during the execution of a relation hook20:52
marcoceppiso you'll want to cache them somewhere20:52
marcoceppiso you can use them later20:52
jrwrenmarcoceppi: huh, ok. so... no point in aiming for stateless hooks?20:53
marcoceppialternatively, you can list all the relations_ids, find the relation_id you want, then get all the units20:53
marcoceppijrwren: you can do that20:53
marcoceppijrwren: IIRC, relation-id is comprised of <relation-name>:<an-arbitrary-number>20:53
marcoceppiso you can infer what relation_id you need by checking the start of the string of the list of items core.hookenv.relation_ids() provides20:54
jrwrenmarcoceppi: This sounds good.20:54
marcoceppithen there's core.hookenv.related_units(rid) which will give you a list of all the units in that relation id20:54
jrwrenmarcoceppi: isn't that a different format of rid?20:55
marcoceppiusing those two pieces of information, jrwren, you should be able to loop through and call relation_get(rid=relation_id, unit=u)20:55
marcoceppirid and relation_id are interchangable in this context20:55
jrwrenmarcoceppi: the call to related_units() still takes a relation:# format? will it work even if # doesn't exist?20:56
* marcoceppi will bug Tim VanSteenburger to update the docs on pythonhosted.org20:56
marcoceppijrwren: probably not, that depends on how flexible juju is20:56
marcoceppisince it's just a passthrough to `relation-units -r <relation_id>`20:57
jrwrenmarcoceppi: Then list and startswith it shall be.20:57
marcoceppiworth a try, but I'm guessing no20:57
jrwrenmarcoceppi: understood. The source is easy enough to read, its just what <relation_id> is there, which is unknown.20:57
marcoceppiright, that's something juju makes up20:57
marcoceppitypically out of thin air ;) but should follow relation:<id>20:57
marcoceppithe idea being, if you break and recreate20:58
marcoceppiyou'll get a new unique relation id20:58
marcoceppiwhich may or may not be incremental from the last20:58
jrwrenIt would be very nice if all this was documented on links from https://juju.ubuntu.com/docs/authors-charm-writing.html too.21:00
marcoceppijrwren: it's on the roadmap21:03
marcoceppiboth charmhelpers and better author docs21:03
jrwrenmarcoceppi: Thank you for your help.21:04
marcoceppijrwren: np, feel free to ping if you have any others21:04
marcoceppifwiw, a lot of the openstack charms have atomic-like functions that do relation calls, so there's use of this pattern in charms already21:05
jrwrenmarcoceppi: I cannot call relation-ids or relation-list without a relation name21:25
jrwrenmarcoceppi: I'm pretty sure that hookenv.relation_ids() will always fail.21:25
jrwrenmarcoceppi: As will hookenv.related_units()21:26
marcoceppirelated_units needs a relation_id21:26
marcoceppijrwren: it looks like relation-ids takes a relation now21:27
marcoceppiwhich is cool21:27
marcoceppijrwren: so you can say, "db" or whatever the relation name is21:27
marcoceppiand get the ID that way21:27
marcoceppiisntead of having to iterate through a list21:27
marcoceppiyou'll either get a value or None iirc21:27
jrwrenthat is good.21:27
marcoceppirather, a list of relation ids21:27
marcoceppifor that relation21:27
marcoceppiin case there's more than one21:28
marcoceppiIE, MySQL -> WordPress, MySQL -> MediaWiki21:28
marcoceppiquery database on MySQL you'll get two relation ids21:28
marcoceppiloop through the ids to get the units, etc, etc21:28
jrwrenmarcoceppi: indeed. I must have misunderstood what you wrote before.21:28
=== CyberJacob|Away is now known as CyberJacob
=== cmagina_ is now known as cmagina
oskarshey all, has anyone set up multiple l3 agents with the quantum-gateay charm?22:23
oskarsI feel like i'm frustratingly close to getting it working, but i'm getting a TooManyExternalNetwroks exception in the nova-server logs.22:24
oskarsit also seems to be taking away my ability to spell things correctly22:24
=== CyberJacob is now known as CyberJacob|Away

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!