Browse Source

Configuring analyst for OPSVM

Ticket: [SOL-1144]
Signed-off-by: Junaid Ali <junaidali@plumgrid.com>
plumgrid 2 years ago
parent
commit
77a25e2225
3 changed files with 31 additions and 2 deletions
  1. 3
    1
      hooks/pg_gw_hooks.py
  2. 26
    0
      hooks/pg_gw_utils.py
  3. 2
    1
      unit_tests/test_pg_gw_hooks.py

+ 3
- 1
hooks/pg_gw_hooks.py View File

@@ -35,7 +35,8 @@ from pg_gw_utils import (
35 35
     restart_on_change,
36 36
     restart_on_stop,
37 37
     director_cluster_ready,
38
-    configure_pg_sources
38
+    configure_pg_sources,
39
+    configure_analyst_opsvm
39 40
 )
40 41
 
41 42
 hooks = Hooks()
@@ -69,6 +70,7 @@ def plumgrid_changed():
69 70
     '''
70 71
     if director_cluster_ready():
71 72
         ensure_mtu()
73
+        configure_analyst_opsvm()
72 74
         CONFIGS.write_all()
73 75
 
74 76
 

+ 26
- 0
hooks/pg_gw_utils.py View File

@@ -93,6 +93,32 @@ def configure_pg_sources():
93 93
         log('Unable to update /etc/apt/sources.list')
94 94
 
95 95
 
96
+def configure_analyst_opsvm():
97
+    '''
98
+    Configures Anaylyst for OPSVM
99
+    '''
100
+    opsvm_ip = pg_gw_context._pg_dir_context()['opsvm_ip']
101
+    if not service_running('plumgrid'):
102
+        restart_pg()
103
+    NS_ENTER = ('/opt/local/bin/nsenter -t $(ps ho pid --ppid $(cat '
104
+                '/var/run/libvirt/lxc/plumgrid.pid)) -m -n -u -i -p ')
105
+    sigmund_stop = NS_ENTER + '/usr/bin/service plumgrid-sigmund stop'
106
+    sigmund_status = NS_ENTER \
107
+        + '/usr/bin/service plumgrid-sigmund status'
108
+    sigmund_autoboot = NS_ENTER \
109
+        + '/usr/bin/sigmund-configure --ip {0} --start --autoboot' \
110
+        .format(opsvm_ip)
111
+    try:
112
+        status = subprocess.check_output(sigmund_status, shell=True)
113
+        if 'start/running' in status:
114
+            if subprocess.call(sigmund_stop, shell=True):
115
+                log('plumgrid-sigmund couldn\'t be stopped!')
116
+                return
117
+        subprocess.check_call(sigmund_autoboot, shell=True)
118
+    except:
119
+        log('plumgrid-sigmund couldn\'t be started!')
120
+
121
+
96 122
 def determine_packages():
97 123
     '''
98 124
     Returns list of packages required by PLUMgrid Gateway as specified

+ 2
- 1
unit_tests/test_pg_gw_hooks.py View File

@@ -30,7 +30,8 @@ TO_PATCH = [
30 30
     'determine_packages',
31 31
     'load_iptables',
32 32
     'director_cluster_ready',
33
-    'status_set'
33
+    'status_set',
34
+    'configure_analyst_opsvm'
34 35
 ]
35 36
 NEUTRON_CONF_DIR = "/etc/neutron"
36 37
 

Loading…
Cancel
Save