~junaidali/charms/trusty/plumgrid-gateway/mgmt_val

« back to all changes in this revision

Viewing changes to hooks/pg_gw_context.py

  • Committer: Bilal Baqar
  • Date: 2016-03-14 06:43:21 UTC
  • mfrom: (18.4.2 plumgrid-gateway)
  • Revision ID: bbaqar@plumgrid.com-20160314064321-af3xlaktrkakgbbh
Made the following changes:
1. Reordered file and module imports
2. Sorted director IPs
3. Added unit fqdn in /etc/hosts of plumgrid-lxc
4. Loading plumgrid specific iptables on install
5. Added temporary upgrade hook to load iptables
6. stop_pg() is being used in restart_pg()
7. persistant iptables

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
# This file contains the class that generates context for
4
4
# PLUMgrid template files.
5
5
 
 
6
from charmhelpers.contrib.openstack import context
 
7
from charmhelpers.contrib.openstack.utils import get_host_ip
6
8
from charmhelpers.core.hookenv import (
7
9
    relation_ids,
8
10
    related_units,
9
11
    relation_get,
10
12
)
11
 
from charmhelpers.contrib.openstack import context
12
 
from charmhelpers.contrib.openstack.utils import get_host_ip
13
 
from socket import gethostname as get_unit_hostname
 
13
from socket import (
 
14
    gethostname,
 
15
    getfqdn
 
16
)
14
17
 
15
18
 
16
19
def _pg_dir_settings():
60
63
            return {}
61
64
 
62
65
        pg_dir_ips = ''
63
 
        pg_dir_settings = _pg_dir_settings()
 
66
        pg_dir_settings = sorted(_pg_dir_settings())
64
67
        single_ip = True
65
68
        for ip in pg_dir_settings:
66
69
            if single_ip:
69
72
            else:
70
73
                pg_dir_ips = pg_dir_ips + ',' + str(ip)
71
74
        pg_ctxt['local_ip'] = pg_dir_ips
72
 
        unit_hostname = get_unit_hostname()
 
75
        unit_hostname = gethostname()
73
76
        pg_ctxt['pg_hostname'] = unit_hostname
 
77
        pg_ctxt['pg_fqdn'] = getfqdn()
74
78
        from pg_gw_utils import (
75
79
            get_mgmt_interface,
76
80
            get_gw_interfaces,