=== 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 | ||
gnuoy | jamespage, 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 moment | 14: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__ | ||
jrwren | What is the right way to use charmhelpers.core.hookenv.relation_get ? I do not like that it is outputting errors. | 20:43 |
marcoceppi | jrwren: what errors are you getting? | 20:43 |
jrwren | no relation id specified | 20:44 |
marcoceppi | jrwren: is this being called out of band of a relation call? | 20:45 |
marcoceppi | of a relation hook* | 20:45 |
marcoceppi | alternatively, just supply the current JUJU_RELATION_ID | 20:45 |
marcoceppi | from os.environ | 20:45 |
marcoceppi | jrwren: give me a min to open the code, the docs are light on this one | 20:47 |
jrwren | yes, out of band. I should look it up. | 20:47 |
marcoceppi | jrwren: docs are here, FYI: http://pythonhosted.org//charmhelpers/api/charmhelpers.core.html#charmhelpers.core.hookenv.relation_get | 20:47 |
marcoceppi | jrwren: in that case you need to provide the JUJU_RELATION_ID and the unit you wish to query this information | 20:47 |
marcoceppi | during a relation hook, both JUJU_RELATION_ID and JUJU_REMOTE_UNIT are environment variables set in the hook environment | 20:47 |
marcoceppi | jrwren: hum, the docs are out of date with the function signature | 20:49 |
marcoceppi | you pass unit and relation_id as parameters | 20:49 |
marcoceppi | elation_get(attribute=None, unit=None, rid=None) | 20:49 |
marcoceppi | relation_get(attribute=None, unit=None, rid=None) | 20:49 |
marcoceppi | tvansteenburgh: can we get the docs re-generated? | 20:50 |
jrwren | marcoceppi: where are the format of rid and unit documented? | 20:50 |
marcoceppi | jrwren: the format are the values of JUJU_RELATION_ID and JUJU_REMOTE_UNIT respectively | 20:51 |
marcoceppi | remote unit being in the format of "service/#" | 20:51 |
marcoceppi | relation id is typically "text:#" | 20:51 |
marcoceppi | you can query them using relation_id | 20:51 |
marcoceppi | you can query them using relation_ids* | 20:51 |
jrwren | I didn't have much like with any of that when I was debugging the hooks. I'll try again. | 20:52 |
marcoceppi | jrwren: they're only set during the execution of a relation hook | 20:52 |
marcoceppi | so you'll want to cache them somewhere | 20:52 |
marcoceppi | so you can use them later | 20:52 |
jrwren | marcoceppi: huh, ok. so... no point in aiming for stateless hooks? | 20:53 |
marcoceppi | alternatively, you can list all the relations_ids, find the relation_id you want, then get all the units | 20:53 |
marcoceppi | jrwren: you can do that | 20:53 |
marcoceppi | jrwren: IIRC, relation-id is comprised of <relation-name>:<an-arbitrary-number> | 20:53 |
marcoceppi | so you can infer what relation_id you need by checking the start of the string of the list of items core.hookenv.relation_ids() provides | 20:54 |
jrwren | marcoceppi: This sounds good. | 20:54 |
marcoceppi | then there's core.hookenv.related_units(rid) which will give you a list of all the units in that relation id | 20:54 |
jrwren | marcoceppi: isn't that a different format of rid? | 20:55 |
marcoceppi | using those two pieces of information, jrwren, you should be able to loop through and call relation_get(rid=relation_id, unit=u) | 20:55 |
marcoceppi | rid and relation_id are interchangable in this context | 20:55 |
jrwren | marcoceppi: 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.org | 20:56 | |
marcoceppi | jrwren: probably not, that depends on how flexible juju is | 20:56 |
marcoceppi | since it's just a passthrough to `relation-units -r <relation_id>` | 20:57 |
jrwren | marcoceppi: Then list and startswith it shall be. | 20:57 |
marcoceppi | worth a try, but I'm guessing no | 20:57 |
jrwren | marcoceppi: understood. The source is easy enough to read, its just what <relation_id> is there, which is unknown. | 20:57 |
marcoceppi | right, that's something juju makes up | 20:57 |
marcoceppi | typically out of thin air ;) but should follow relation:<id> | 20:57 |
marcoceppi | the idea being, if you break and recreate | 20:58 |
marcoceppi | you'll get a new unique relation id | 20:58 |
marcoceppi | which may or may not be incremental from the last | 20:58 |
jrwren | It would be very nice if all this was documented on links from https://juju.ubuntu.com/docs/authors-charm-writing.html too. | 21:00 |
marcoceppi | jrwren: it's on the roadmap | 21:03 |
marcoceppi | both charmhelpers and better author docs | 21:03 |
jrwren | marcoceppi: Thank you for your help. | 21:04 |
marcoceppi | jrwren: np, feel free to ping if you have any others | 21:04 |
marcoceppi | fwiw, a lot of the openstack charms have atomic-like functions that do relation calls, so there's use of this pattern in charms already | 21:05 |
jrwren | marcoceppi: I cannot call relation-ids or relation-list without a relation name | 21:25 |
jrwren | marcoceppi: I'm pretty sure that hookenv.relation_ids() will always fail. | 21:25 |
jrwren | marcoceppi: As will hookenv.related_units() | 21:26 |
marcoceppi | related_units needs a relation_id | 21:26 |
marcoceppi | jrwren: it looks like relation-ids takes a relation now | 21:27 |
marcoceppi | which is cool | 21:27 |
marcoceppi | jrwren: so you can say, "db" or whatever the relation name is | 21:27 |
marcoceppi | and get the ID that way | 21:27 |
marcoceppi | isntead of having to iterate through a list | 21:27 |
marcoceppi | you'll either get a value or None iirc | 21:27 |
jrwren | that is good. | 21:27 |
marcoceppi | rather, a list of relation ids | 21:27 |
marcoceppi | for that relation | 21:27 |
marcoceppi | in case there's more than one | 21:28 |
marcoceppi | IE, MySQL -> WordPress, MySQL -> MediaWiki | 21:28 |
marcoceppi | query database on MySQL you'll get two relation ids | 21:28 |
marcoceppi | loop through the ids to get the units, etc, etc | 21:28 |
jrwren | marcoceppi: indeed. I must have misunderstood what you wrote before. | 21:28 |
=== CyberJacob|Away is now known as CyberJacob | ||
=== cmagina_ is now known as cmagina | ||
oskars | hey all, has anyone set up multiple l3 agents with the quantum-gateay charm? | 22:23 |
oskars | I feel like i'm frustratingly close to getting it working, but i'm getting a TooManyExternalNetwroks exception in the nova-server logs. | 22:24 |
oskars | it also seems to be taking away my ability to spell things correctly | 22:24 |
=== CyberJacob is now known as CyberJacob|Away |
Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!