blob: 1d450ebf9db733771e74a3af60ac98cb07900257 [file] [log] [blame]
Ray Milkeya2b52b42019-02-07 09:25:27 -08001#!/usr/bin/env python
2
Ray Milkeyb2e6be82019-03-06 14:58:42 -08003import subprocess
4import sys
5import json
6import os
Ray Milkeya2b52b42019-02-07 09:25:27 -08007
8REQUIRED_APPS = ["org.onosproject.drivers"]
9
10
11def _main():
12 # Get the ONOS node address
Ray Milkeya2b52b42019-02-07 09:25:27 -080013 if len(sys.argv) > 1:
14 onos_node = sys.argv[1]
15 else:
16 onos_node = os.environ["OCI"]
17
18 # Get a JSON representation of the apps that are currently running
19 current_apps_json = subprocess.check_output(["onos", onos_node, "onos:apps", "-a", "-s", "-j"])
20
21 # Determine which apps need to be deactivated
22 apps_to_deactivate = []
23 config = json.loads(current_apps_json)
24
25 for app_description in config:
Ray Milkeyb2e6be82019-03-06 14:58:42 -080026 app_name = app_description["name"]
27 if app_name not in REQUIRED_APPS:
28 apps_to_deactivate.append(app_name)
Ray Milkeya2b52b42019-02-07 09:25:27 -080029
30 # Deactivate all apps
31 if len(apps_to_deactivate) > 0:
32 deactivate_command = ["onos", onos_node, "onos:app", "deactivate"]
33 for app_to_deactivate in apps_to_deactivate:
Ray Milkeyb2e6be82019-03-06 14:58:42 -080034
35 deactivate_command.append(app_to_deactivate)
Ray Milkeya2b52b42019-02-07 09:25:27 -080036 subprocess.check_output(deactivate_command)
37
Ray Milkeya2b52b42019-02-07 09:25:27 -080038
39if __name__ == "__main__":
40 _main()