Merge lp:~junaidali/charms/trusty/plumgrid-director/trunk into lp:~plumgrid-team/charms/trusty/plumgrid-director/trunk

Proposed by Junaid Ali
Status: Merged
Merged at revision: 28
Proposed branch: lp:~junaidali/charms/trusty/plumgrid-director/trunk
Merge into: lp:~plumgrid-team/charms/trusty/plumgrid-director/trunk
Diff against target: 148 lines (+44/-24)
4 files modified
hooks/pg_dir_context.py (+10/-1)
hooks/pg_dir_hooks.py (+22/-18)
hooks/pg_dir_utils.py (+12/-1)
unit_tests/test_pg_dir_hooks.py (+0/-4)
To merge this branch: bzr merge lp:~junaidali/charms/trusty/plumgrid-director/trunk
Reviewer Review Type Date Requested Status
Bilal Baqar Approve
Hassaan Pasha Pending
Review via email: mp+288399@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Bilal Baqar (bbaqar) wrote :

Made a few comments.

review: Needs Fixing
Revision history for this message
Bilal Baqar (bbaqar) :
review: Needs Fixing
27. By Bilal Baqar

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

28. By Bilal Baqar

Improved config-changed hook to perform steps according to the config changed

Revision history for this message
Bilal Baqar (bbaqar) :
review: Approve
Revision history for this message
Bilal Baqar (bbaqar) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/pg_dir_context.py'
2--- hooks/pg_dir_context.py 2016-03-12 20:38:52 +0000
3+++ hooks/pg_dir_context.py 2016-03-25 13:15:20 +0000
4@@ -6,7 +6,6 @@
5 import re
6 from charmhelpers.contrib.openstack import context
7 from charmhelpers.contrib.openstack.utils import get_host_ip
8-from charmhelpers.contrib.network.ip import get_address_in_network
9 from charmhelpers.core.hookenv import (
10 config,
11 unit_get,
12@@ -16,6 +15,11 @@
13 related_units,
14 relation_get,
15 )
16+from charmhelpers.contrib.network.ip import (
17+ is_ip,
18+ get_address_in_network,
19+)
20+
21 from socket import (
22 gethostname,
23 getfqdn
24@@ -84,6 +88,11 @@
25 else:
26 pg_dir_ips_string = pg_dir_ips_string + ',' + str(ip)
27 pg_ctxt['director_ips_string'] = pg_dir_ips_string
28+ PG_VIP = config('plumgrid-virtual-ip')
29+ if is_ip(PG_VIP):
30+ pg_ctxt['virtual_ip'] = conf['plumgrid-virtual-ip']
31+ else:
32+ raise ValueError('Invalid IP Provided')
33 pg_ctxt['virtual_ip'] = conf['plumgrid-virtual-ip']
34 unit_hostname = gethostname()
35 pg_ctxt['pg_hostname'] = unit_hostname
36
37=== modified file 'hooks/pg_dir_hooks.py'
38--- hooks/pg_dir_hooks.py 2016-03-13 03:50:51 +0000
39+++ hooks/pg_dir_hooks.py 2016-03-25 13:15:20 +0000
40@@ -7,6 +7,7 @@
41
42 import sys
43 import time
44+from charmhelpers.core.host import service_running
45
46 from charmhelpers.core.hookenv import (
47 Hooks,
48@@ -69,33 +70,36 @@
49 This hook is run when a config parameter is changed.
50 It also runs on node reboot.
51 '''
52- if add_lcm_key():
53- log("PLUMgrid LCM Key added")
54- return 1
55 charm_config = config()
56+ if charm_config.changed('lcm-ssh-key'):
57+ if add_lcm_key():
58+ log("PLUMgrid LCM Key added")
59 if charm_config.changed('plumgrid-license-key'):
60 if post_pg_license():
61 log("PLUMgrid License Posted")
62- return 1
63 if charm_config.changed('fabric-interfaces'):
64 if not fabric_interface_changed():
65 log("Fabric interface already set")
66- return 1
67- if charm_config.changed('os-data-network'):
68- if charm_config['fabric-interfaces'] == 'MANAGEMENT':
69- log('Fabric running on managment network')
70- return 1
71- stop_pg()
72- configure_sources(update=True)
73- pkgs = determine_packages()
74- for pkg in pkgs:
75- apt_install(pkg, options=['--force-yes'], fatal=True)
76- remove_iovisor()
77- load_iovisor()
78+ else:
79+ stop_pg()
80+ if charm_config.changed('plumgrid-virtual-ip'):
81+ CONFIGS.write_all()
82+ stop_pg()
83+ if (charm_config.changed('install_sources') or
84+ charm_config.changed('plumgrid-build') or
85+ charm_config.changed('install_keys') or
86+ charm_config.changed('iovisor-build')):
87+ stop_pg()
88+ configure_sources(update=True)
89+ pkgs = determine_packages()
90+ for pkg in pkgs:
91+ apt_install(pkg, options=['--force-yes'], fatal=True)
92+ remove_iovisor()
93+ load_iovisor()
94 ensure_mtu()
95- add_lcm_key()
96 CONFIGS.write_all()
97- restart_pg()
98+ if not service_running('plumgrid'):
99+ restart_pg()
100
101
102 @hooks.hook('start')
103
104=== modified file 'hooks/pg_dir_utils.py'
105--- hooks/pg_dir_utils.py 2016-03-12 21:34:47 +0000
106+++ hooks/pg_dir_utils.py 2016-03-25 13:15:20 +0000
107@@ -30,6 +30,7 @@
108 from charmhelpers.core.host import (
109 service_start,
110 service_stop,
111+ service_running
112 )
113 from charmhelpers.fetch import (
114 apt_cache,
115@@ -142,7 +143,17 @@
116 '''
117 stop_pg()
118 service_start('plumgrid')
119- time.sleep(5)
120+ time.sleep(3)
121+ if not service_running('plumgrid'):
122+ if service_running('libvirt-bin'):
123+ raise ValueError("plumgrid service couldn't be started")
124+ else:
125+ if service_start('libvirt-bin'):
126+ time.sleep(3)
127+ if not service_running('plumgrid'):
128+ raise ValueError("plumgrid service couldn't be started")
129+ else:
130+ raise ValueError("libvirt-bin service couldn't be started")
131
132
133 def stop_pg():
134
135=== modified file 'unit_tests/test_pg_dir_hooks.py'
136--- unit_tests/test_pg_dir_hooks.py 2016-03-10 19:38:25 +0000
137+++ unit_tests/test_pg_dir_hooks.py 2016-03-25 13:15:20 +0000
138@@ -62,10 +62,6 @@
139 self.load_iovisor.assert_called_with()
140 self.ensure_mtu.assert_called_with()
141
142- def test_config_changed_hook(self):
143- self.add_lcm_key.return_value = 1
144- self._call_hook('config-changed')
145-
146 def test_start(self):
147 self._call_hook('start')
148 self.test_config.set('plumgrid-license-key', None)

Subscribers

People subscribed via source and target branches