Browse Source

Merge pull request #1 from plumgrid/junaid-dev

Solutions API changes
tags/14.04-eol
Junaid Ali 2 years ago
parent
commit
51ee6c9edf
3 changed files with 23 additions and 2 deletions
  1. 11
    0
      hooks/pg_gw_hooks.py
  2. 11
    2
      hooks/pg_gw_utils.py
  3. 1
    0
      hooks/plumgrid-relation-joined

+ 11
- 0
hooks/pg_gw_hooks.py View File

@@ -12,6 +12,7 @@ from charmhelpers.core.hookenv import (
12 12
     UnregisteredHookError,
13 13
     log,
14 14
     config,
15
+    relation_set,
15 16
     status_set
16 17
 )
17 18
 
@@ -74,6 +75,16 @@ def plumgrid_changed():
74 75
         CONFIGS.write_all()
75 76
 
76 77
 
78
+@hooks.hook('plumgrid-relation-joined')
79
+def gateway_node_joined(relation_id=None):
80
+    '''
81
+    This hook is run when relation between plumgrid-gateway and
82
+    plumgrid-director is made.
83
+    '''
84
+    rel_data = {'gateway-peer': 'gateway-peer'}
85
+    relation_set(relation_id=relation_id, **rel_data)
86
+
87
+
77 88
 @hooks.hook('config-changed')
78 89
 @restart_on_stop()
79 90
 @restart_on_change(restart_map())

+ 11
- 2
hooks/pg_gw_utils.py View File

@@ -21,6 +21,8 @@ from charmhelpers.core.hookenv import (
21 21
 )
22 22
 from charmhelpers.contrib.network.ip import (
23 23
     get_iface_from_addr,
24
+    get_host_ip,
25
+    get_iface_addr,
24 26
     get_bridges,
25 27
     get_bridge_nics,
26 28
 )
@@ -97,9 +99,9 @@ def configure_analyst_opsvm():
97 99
     '''
98 100
     Configures Anaylyst for OPSVM
99 101
     '''
100
-    opsvm_ip = pg_gw_context._pg_dir_context()['opsvm_ip']
101 102
     if not service_running('plumgrid'):
102 103
         restart_pg()
104
+    opsvm_ip = pg_gw_context._pg_dir_context()['opsvm_ip']
103 105
     NS_ENTER = ('/opt/local/bin/nsenter -t $(ps ho pid --ppid $(cat '
104 106
                 '/var/run/libvirt/lxc/plumgrid.pid)) -m -n -u -i -p ')
105 107
     sigmund_stop = NS_ENTER + '/usr/bin/service plumgrid-sigmund stop'
@@ -115,6 +117,7 @@ def configure_analyst_opsvm():
115 117
                 log('plumgrid-sigmund couldn\'t be stopped!')
116 118
                 return
117 119
         subprocess.check_call(sigmund_autoboot, shell=True)
120
+        status = subprocess.check_output(sigmund_status, shell=True)
118 121
     except:
119 122
         log('plumgrid-sigmund couldn\'t be started!')
120 123
 
@@ -249,7 +252,13 @@ def get_mgmt_interface():
249 252
     '''
250 253
     mgmt_interface = config('mgmt-interface')
251 254
     if not mgmt_interface:
252
-        return get_iface_from_addr(unit_get('private-address'))
255
+        try:
256
+            return get_iface_from_addr(unit_get('private-address'))
257
+        except:
258
+            for bridge_interface in get_bridges():
259
+                if (get_host_ip(unit_get('private-address'))
260
+                        in get_iface_addr(bridge_interface)):
261
+                    return bridge_interface
253 262
     elif interface_exists(mgmt_interface):
254 263
         return mgmt_interface
255 264
     else:

+ 1
- 0
hooks/plumgrid-relation-joined View File

@@ -0,0 +1 @@
1
+pg_gw_hooks.py

Loading…
Cancel
Save