Merge lp://qastaging/~james-page/charm-helpers/is-relation-made into lp://qastaging/charm-helpers

Proposed by James Page
Status: Merged
Merged at revision: 92
Proposed branch: lp://qastaging/~james-page/charm-helpers/is-relation-made
Merge into: lp://qastaging/charm-helpers
Diff against target: 260 lines (+109/-18)
7 files modified
charmhelpers/cli/host.py (+1/-0)
charmhelpers/contrib/ssl/__init__.py (+7/-8)
charmhelpers/core/hookenv.py (+20/-0)
charmhelpers/fetch/bzrurl.py (+1/-1)
tests/contrib/ssl/test_ssl.py (+1/-5)
tests/core/test_hookenv.py (+79/-0)
tests/fetch/test_bzrurl.py (+0/-4)
To merge this branch: bzr merge lp://qastaging/~james-page/charm-helpers/is-relation-made
Reviewer Review Type Date Requested Status
James Page Needs Resubmitting
Adam Gandelman (community) Needs Fixing
Review via email: mp+191920@code.qastaging.launchpad.net

Description of the change

Add is_relation_made helper for deep testing of relation state.

For example, the ceph charm only passes an auth key to clients once
its bootstrapped; until then the client can do anything:

  if is_relation_made('ceph:0', 'key'):
     configure_and_do_stuff()
  else:
     don_t()

Unit tests as well.

Thanks for looking.

To post a comment you must log in.
Revision history for this message
James Page (james-page) wrote :

I also tidied the majority of lint in the project;

make lint is a good check when reviewing merge proposals; don't think everyone has been doing that!

82. By James Page

Rebase against parent branch

83. By James Page

Rebase on parent

Revision history for this message
Adam Gandelman (gandelman-a) wrote :

This looks good, but any chance we can allow is_relation_made() to also take a list of keys? That way we could use the same for relations that require a bit more data, ie:

keys = ['password, 'db-host']
if is_relation_made('shared-db:0', settings):
    configure_db()

Revision history for this message
Adam Gandelman (gandelman-a) wrote :

Also, I think the current behavior of relation_get() will cause this to evalutate as True even if the relation setting has not been set:

if relation_get(key, rid=r_id, unit=unit):
   return True

Might be a good idea to also check whatever relation_get() returns != ''

review: Needs Fixing
84. By James Page

Add support for multiple key checks in is_relation_made

85. By James Page

Rework a bit for lists

Revision history for this message
James Page (james-page) wrote :

relation_get for a missing key should always return None so I think that is OK.

I updated to support lists as well as single strings as keys.

review: Needs Resubmitting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches