Browse Source

Updated config-changed hook and restart_pg()

tags/14.04-eol
Junaid Ali 3 years ago
parent
commit
2e99af9387
2 changed files with 9 additions and 4 deletions
  1. 7
    3
      hooks/pg_gw_hooks.py
  2. 2
    1
      hooks/pg_gw_utils.py

+ 7
- 3
hooks/pg_gw_hooks.py View File

@@ -14,6 +14,8 @@ from charmhelpers.core.hookenv import (
14 14
     config,
15 15
 )
16 16
 
17
+from charmhelpers.core.host import service_running
18
+
17 19
 from charmhelpers.fetch import (
18 20
     apt_install,
19 21
     apt_purge,
@@ -82,13 +84,12 @@ def config_changed():
82 84
         if not fabric_interface_changed():
83 85
             log("Fabric interface already set")
84 86
         else:
85
-            restart_pg()
87
+            stop_pg()
86 88
     if charm_config.changed('os-data-network'):
87 89
         if charm_config['fabric-interfaces'] == 'MANAGEMENT':
88 90
             log('Fabric running on managment network')
89 91
     if (charm_config.changed('install_sources') or
90 92
         charm_config.changed('plumgrid-build') or
91
-        charm_config.changed('plumgrid-virtual-ip') or
92 93
             charm_config.changed('iovisor-build')):
93 94
         stop_pg()
94 95
         configure_sources(update=True)
@@ -97,8 +98,11 @@ def config_changed():
97 98
             apt_install(pkg, options=['--force-yes'], fatal=True)
98 99
             remove_iovisor()
99 100
             load_iovisor()
100
-        restart_pg()
101 101
     CONFIGS.write_all()
102
+    # Restarting the plumgrid service only if it is
103
+    # already stopped by any config-parameters or node reboot
104
+    if not service_running('plumgrid'):
105
+        restart_pg()
102 106
 
103 107
 
104 108
 @hooks.hook('upgrade-charm')

+ 2
- 1
hooks/pg_gw_utils.py View File

@@ -148,7 +148,8 @@ def restart_pg():
148 148
             # wait for 3 secs so that libvirt-bin can be completely up and
149 149
             # start the plumgrid service
150 150
             time.sleep(3)
151
-            service_start('plumgrid')
151
+            if not service_start('plumgrid'):
152
+                raise ValueError("plumgrid service couldn't be started")
152 153
     time.sleep(30)
153 154
 
154 155
 

Loading…
Cancel
Save