| REQUIRED_APPS = ["org.onosproject.drivers"] |
| # Get the ONOS node address |
| 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 |
| 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) |
| 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__": |