1
from charmhelpers.core.hookenv import (
6
from charmhelpers.contrib.openstack import context
8
from socket import gethostname as get_unit_hostname
11
#This function will be used to get information from neutron-api
12
def _neutron_api_settings():
14
'neutron_security_groups': False,
15
'l2_population': True,
16
'overlay_network_type': 'gre',
18
for rid in relation_ids('neutron-plugin-api'):
19
for unit in related_units(rid):
20
rdata = relation_get(rid=rid, unit=unit)
21
if 'l2-population' not in rdata:
24
'l2_population': rdata['l2-population'],
25
'neutron_security_groups': rdata['neutron-security-groups'],
26
'overlay_network_type': rdata['overlay-network-type'],
28
# Override with configuration if set to true
29
if config('disable-security-groups'):
30
neutron_settings['neutron_security_groups'] = False
31
return neutron_settings
32
return neutron_settings
36
#Use this function to get information from the director
37
def _pg_dir_settings():
39
Inspects current plumgrid relation
42
'pg_dir_ip': '192.168.100.201',
44
for rid in relation_ids('plumgrid'):
45
for unit in related_units(rid):
46
rdata = relation_get(rid=rid, unit=unit)
48
'pg_dir_ip': rdata['private-address'],
53
class PGEdgeContext(context.NeutronContext):
61
def network_manager(self):
64
def _save_flag_file(self):
68
#def neutron_security_groups(self):
69
# neutron_api_settings = _neutron_api_settings()
70
# return neutron_api_settings['neutron_security_groups']
73
#Generated Config for all Plumgrid templates inside
75
pg_ctxt = super(PGEdgeContext, self).pg_ctxt()
80
pg_dir_settings = _pg_dir_settings()
81
pg_ctxt['local_ip'] = pg_dir_settings['pg_dir_ip']
82
#neutron_api_settings = _neutron_api_settings()
83
pg_ctxt['pg_hostname'] = "pg-edge"
84
pg_ctxt['interface'] = "juju-br0"
85
pg_ctxt['label'] = get_unit_hostname()
86
pg_ctxt['fabric_mode'] = 'host'