~gnuoy/charms/trusty/openstack-dashboard/plugin-relation

« back to all changes in this revision

Viewing changes to hooks/horizon_contexts.py

  • Committer: Michał Sawicz
  • Date: 2015-05-28 10:00:06 UTC
  • Revision ID: michal.sawicz@canonical.com-20150528100006-p8x8wgyfk4awrw22
Unit might not be there yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
181
181
        settings = []
182
182
        
183
183
        for rid in relation_ids("settings"):
184
 
            unit = related_units(rid)[0]
185
 
            rdata = relation_get(unit=unit, rid=rid)
186
 
            if 'setting' in rdata:
187
 
                settings.append('# {0}\n{1}'.format(
188
 
                    unit, rdata['setting'])
189
 
                )
 
184
            try:
 
185
                unit = related_units(rid)[0]
 
186
            except IndexError:
 
187
                pass
 
188
            else:
 
189
                rdata = relation_get(unit=unit, rid=rid)
 
190
                if 'setting' in rdata:
 
191
                    settings.append('# {0}\n{1}'.format(
 
192
                        unit, rdata['setting'])
 
193
                    )
190
194
        ctxt = {
191
195
            'settings': settings
192
196
        }