~junaidali/charms/trusty/plumgrid-gateway/oil-sapi-changes

« back to all changes in this revision

Viewing changes to hooks/pg_gw_context.py

  • Committer: Hassaan Pasha
  • Date: 2015-08-10 09:57:25 UTC
  • Revision ID: hassaanp@plumgrid.com-20150810095725-6z8v3g73ts8okykq
Added HA coverage

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
    '''
18
18
    Inspects relation with PLUMgrid director.
19
19
    '''
20
 
    pg_settings = {
21
 
        'pg_dir_ip': '192.168.100.201',
22
 
    }
 
20
    director_ips=[]
23
21
    for rid in relation_ids('plumgrid'):
24
22
        for unit in related_units(rid):
25
23
            rdata = relation_get(rid=rid, unit=unit)
26
 
            pg_settings = {
27
 
                'pg_dir_ip': rdata['private-address'],
28
 
            }
29
 
    return pg_settings
30
 
 
 
24
            director_ips.append(str(rdata['private-address']))
 
25
    return director_ips
31
26
 
32
27
class PGGwContext(context.NeutronContext):
33
28
 
63
58
            return {}
64
59
 
65
60
        conf = config()
 
61
        pg_dir_ips = ''
66
62
        pg_dir_settings = _pg_dir_settings()
67
 
        pg_ctxt['local_ip'] = pg_dir_settings['pg_dir_ip']
68
 
 
 
63
        single_ip = True
 
64
        for ip in pg_dir_settings:
 
65
            if single_ip:
 
66
                pg_dir_ips=str(ip)
 
67
                single_ip = False
 
68
            else:
 
69
                pg_dir_ips= pg_dir_ips + ',' + str(ip)
 
70
        pg_ctxt['local_ip'] = pg_dir_ips
69
71
        unit_hostname = get_unit_hostname()
70
72
        pg_ctxt['pg_hostname'] = unit_hostname
71
 
        pg_ctxt['interface'] = "juju-br0"
 
73
        from pg_gw_utils import check_interface_type
 
74
        interface_type = check_interface_type()
 
75
        pg_ctxt['interface'] = interface_type
72
76
        pg_ctxt['label'] = unit_hostname
73
77
        pg_ctxt['fabric_mode'] = 'host'
74
78