Browse Source

Ensuring plumgrid services to restart on certain hooks, Updated restart_pg()

Junaid Ali 3 years ago
parent
commit
f8987ff8ca
2 changed files with 25 additions and 17 deletions
  1. 17
    16
      hooks/pg_gw_hooks.py
  2. 8
    1
      hooks/pg_gw_utils.py

+ 17
- 16
hooks/pg_gw_hooks.py View File

@@ -74,30 +74,31 @@ def config_changed():
74 74
     This hook is run when a config parameter is changed.
75 75
     It also runs on node reboot.
76 76
     '''
77
-    if add_lcm_key():
78
-        log("PLUMgrid LCM Key added")
79
-        return 1
80 77
     charm_config = config()
78
+    if charm_config.changed('lcm-ssh-key'):
79
+        if add_lcm_key():
80
+            log("PLUMgrid LCM Key added")
81 81
     if charm_config.changed('fabric-interfaces'):
82 82
         if not fabric_interface_changed():
83 83
             log("Fabric interface already set")
84
-            return 1
84
+        else:
85
+            restart_pg()
85 86
     if charm_config.changed('os-data-network'):
86 87
         if charm_config['fabric-interfaces'] == 'MANAGEMENT':
87 88
             log('Fabric running on managment network')
88
-            return 1
89
-    stop_pg()
90
-    configure_sources(update=True)
91
-    pkgs = determine_packages()
92
-    for pkg in pkgs:
93
-        apt_install(pkg, options=['--force-yes'], fatal=True)
94
-    remove_iovisor()
95
-    load_iovisor()
96
-    ensure_mtu()
97
-    ensure_files()
98
-    add_lcm_key()
89
+    if (charm_config.changed('install_sources') or
90
+        charm_config.changed('plumgrid-build') or
91
+        charm_config.changed('plumgrid-virtual-ip') or
92
+            charm_config.changed('iovisor-build')):
93
+        stop_pg()
94
+        configure_sources(update=True)
95
+        pkgs = determine_packages()
96
+        for pkg in pkgs:
97
+            apt_install(pkg, options=['--force-yes'], fatal=True)
98
+            remove_iovisor()
99
+            load_iovisor()
100
+        restart_pg()
99 101
     CONFIGS.write_all()
100
-    restart_pg()
101 102
 
102 103
 
103 104
 @hooks.hook('upgrade-charm')

+ 8
- 1
hooks/pg_gw_utils.py View File

@@ -141,7 +141,14 @@ def restart_pg():
141 141
     Stops and Starts PLUMgrid service after flushing iptables.
142 142
     '''
143 143
     stop_pg()
144
-    service_start('plumgrid')
144
+    if not service_start('plumgrid'):
145
+        if not service_start('libvirt-bin'):
146
+            raise ValueError("libvirt-bin service couldn't be started")
147
+        else:
148
+            # wait for 3 secs so that libvirt-bin can be completely up and
149
+            # start the plumgrid service
150
+            time.sleep(3)
151
+            service_start('plumgrid')
145 152
     time.sleep(30)
146 153
 
147 154
 

Loading…
Cancel
Save