blob: 1d450ebf9db733771e74a3af60ac98cb07900257 [file] [log] [blame]
#!/usr/bin/env python
import subprocess
import sys
import json
import os
REQUIRED_APPS = ["org.onosproject.drivers"]
def _main():
# Get the ONOS node address
if len(sys.argv) > 1:
onos_node = sys.argv[1]
else:
onos_node = os.environ["OCI"]
# Get a JSON representation of the apps that are currently running
current_apps_json = subprocess.check_output(["onos", onos_node, "onos:apps", "-a", "-s", "-j"])
# Determine which apps need to be deactivated
apps_to_deactivate = []
config = json.loads(current_apps_json)
for app_description in config:
app_name = app_description["name"]
if app_name not in REQUIRED_APPS:
apps_to_deactivate.append(app_name)
# Deactivate all apps
if len(apps_to_deactivate) > 0:
deactivate_command = ["onos", onos_node, "onos:app", "deactivate"]
for app_to_deactivate in apps_to_deactivate:
deactivate_command.append(app_to_deactivate)
subprocess.check_output(deactivate_command)
if __name__ == "__main__":
_main()