├── .gitignore ├── README.md ├── conf ├── pyvvo_config.json └── rwstore.properties ├── debug-scripts ├── README.md ├── goss_sender.py ├── list-simulations.sh ├── python_listener.py ├── run-fncs.sh ├── run-fncsbridge.sh ├── run-goss_sender.sh ├── run-gridlabd.sh ├── runit.sh ├── start-debug.sh └── stop-debug.sh ├── docker-compose.d ├── docker-compose_der-dispatch.yml.dist ├── docker-compose_grid-forecasting.yml.dist ├── docker-compose_pyvvo.yml.dist ├── docker-compose_solar-forecast.yml.dist ├── docker-compose_wsu-restoration.yml.cplex └── docker-compose_wsu-vvo.yml.dist ├── docker-compose.yml ├── docker_install_ubuntu.sh ├── gridappsd-shell ├── remove_containers.sh ├── run.sh └── stop.sh /.gitignore: -------------------------------------------------------------------------------- 1 | dumps 2 | gridappsd 3 | gridappsdmysql 4 | applications 5 | services 6 | .env 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gridappsd-docker 2 | 3 | ## Requirements 4 | - git 5 | - docker version 17.12 or higher 6 | - docker-compose version 1.16.1 or higher 7 | 8 | ## Docker and prerequisite install on OS X 9 | - git 10 | - OS X requires xcode 11 | ``` 12 | xcode-select --install 13 | ``` 14 | 15 | ## Clone or download the repository 16 | ``` 17 | git clone https://github.com/GRIDAPPSD/gridappsd-docker 18 | cd gridappsd-docker 19 | ``` 20 | 21 | ## Install Docker on Ubuntu 22 | - run the docker-ce installation script 23 | ``` 24 | ./docker_install_ubuntu.sh 25 | ``` 26 | - log out of your Ubuntu session and log back in to make the docker groups change active 27 | 28 | ## Start the docker container services 29 | ``` 30 | ./run.sh 31 | ``` 32 | The run.sh does the folowing 33 | - download the mysql dump file 34 | - download the blazegraph data 35 | - start the docker containers 36 | - ingest the blazegraph data 37 | - connect to the gridappsd container 38 | 39 | ## Start gridappsd 40 | 41 | Now we are inside the executing container 42 | ``` 43 | root@737c30c82df7:/gridappsd# ./run-gridappsd.sh 44 | 45 | ``` 46 | Open your browser to http://localhost:8080/ 47 | 48 | [Using GridAPPS-D](https://gridappsd.readthedocs.io/en/master/using_gridappsd/index.html) 49 | 50 | ## Exiting the container and stopping the containers 51 | 52 | ``` 53 | Use Ctrl+C to stop gridappsd from running 54 | exit 55 | ./stop.sh 56 | ``` 57 | 58 | ## Restarting the containers 59 | ``` 60 | ./run.sh 61 | ``` 62 | 63 | ## Reconnecting to the gridappsd container 64 | 65 | Reconnect to the running gridappsd container 66 | ``` 67 | user@foo>docker exec -it gridappsd bash 68 | 69 | ``` 70 | 71 | ## Next Steps 72 | - Add applications/services to the containers (see how ) 73 | 74 | ## Advanced Usage 75 | ### Using GridAPPS-D on a remote system with a local browser 76 | 77 | ## Start the docker container services 78 | ``` 79 | ./run.sh -r 80 | ``` 81 | 82 | ## Start gridappsd 83 | 84 | Now we are inside the executing container 85 | ``` 86 | root@737c30c82df7:/gridappsd# ./run-gridappsd.sh 87 | 88 | ``` 89 | 90 | Open your browser to http://remoteip:8080/ 91 | -------------------------------------------------------------------------------- /conf/pyvvo_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "database": { 3 | "triplex_table": "triplex", 4 | "substation_table": "substation", 5 | "query_buffer_limit": 20000, 6 | "max_connections": 100 7 | }, 8 | "ga": { 9 | "probabilities": { 10 | "mutate_individual": 0.2, 11 | "mutate_bit": 0.05, 12 | "crossover": 0.7 13 | }, 14 | "intervals": { 15 | "sample": 5, 16 | "minimum_timestep": 1, 17 | "model_run": 60 18 | }, 19 | "population_size": 28, 20 | "generations": 3, 21 | "top_fraction": 0.1, 22 | "total_fraction": 0.5, 23 | "tournament_fraction": 0.2, 24 | "log_interval": 10, 25 | "processes": 6, 26 | "process_shutdown_timeout": 5 27 | }, 28 | "limits": { 29 | "voltage_high": 1.05, 30 | "voltage_low": 0.95, 31 | "power_factor_lag": 0.99, 32 | "power_factor_lead": 0.99 33 | }, 34 | "costs": { 35 | "capacitor_switch": 0.1, 36 | "regulator_tap": 0.5, 37 | "energy": 0.08, 38 | "voltage_violation_high": 2, 39 | "voltage_violation_low": 2, 40 | "power_factor_lag": 0.1, 41 | "power_factor_lead": 0.1 42 | }, 43 | "load_model": { 44 | "averaging_interval": "15Min", 45 | "window_size_days": 14, 46 | "filtering_interval_minutes": 60 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /conf/rwstore.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Note: These options are applied when the journal and the triple store are 3 | # first created. 4 | 5 | ## 6 | ## Journal options. 7 | ## 8 | com.bigdata.rwstore.RWStore.readBlobsAsync=false 9 | 10 | # The backing file. This contains all your data. You want to put this someplace 11 | # safe. The default locator will wind up in the directory from which you start 12 | # your servlet container. 13 | com.bigdata.journal.AbstractJournal.file=blazegraph.jnl 14 | 15 | # The persistence engine. Use 'Disk' for the WORM or 'DiskRW' for the RWStore. 16 | com.bigdata.journal.AbstractJournal.bufferMode=DiskRW 17 | 18 | # Setup for the RWStore recycler rather than session protection. 19 | com.bigdata.service.AbstractTransactionService.minReleaseAge=1 20 | 21 | # Enable group commit. See http://wiki.blazegraph.com/wiki/index.php/GroupCommit 22 | com.bigdata.journal.Journal.groupCommit=false 23 | 24 | com.bigdata.btree.writeRetentionQueue.capacity=4000 25 | com.bigdata.btree.BTree.branchingFactor=128 26 | 27 | # 200M initial extent. 28 | com.bigdata.journal.AbstractJournal.initialExtent=209715200 29 | com.bigdata.journal.AbstractJournal.maximumExtent=209715200 30 | 31 | ## 32 | ## Setup for QUADS mode without the full text index. 33 | ## 34 | com.bigdata.rdf.sail.truthMaintenance=false 35 | com.bigdata.rdf.store.AbstractTripleStore.quads=true 36 | com.bigdata.rdf.store.AbstractTripleStore.statementIdentifiers=false 37 | com.bigdata.rdf.store.AbstractTripleStore.textIndex=false 38 | com.bigdata.rdf.store.AbstractTripleStore.axiomsClass=com.bigdata.rdf.axioms.NoAxioms 39 | 40 | # Bump up the branching factor for the lexicon indices on the default kb. 41 | com.bigdata.namespace.kb.lex.com.bigdata.btree.BTree.branchingFactor=400 42 | 43 | # Bump up the branching factor for the statement indices on the default kb. 44 | com.bigdata.namespace.kb.spo.com.bigdata.btree.BTree.branchingFactor=1024 45 | 46 | # Uncomment to enable collection of OS level performance counters. When 47 | # collected they will be self-reported through the /counters servlet and 48 | # the workbench "Performance" tab. 49 | # 50 | # com.bigdata.journal.Journal.collectPlatformStatistics=true 51 | -------------------------------------------------------------------------------- /debug-scripts/README.md: -------------------------------------------------------------------------------- 1 | # Multi terminal debugging 2 | 3 | This folder (debug-scripts) provides a way to start the individual components of gridappsd in 4 | seperate terminals to allow debugging almost independently of the maing goss process. In order 5 | for this to work there are several steps that must be completed. 6 | 7 | 1. Modify docker-compose.yml file to mount this directory in the container at 8 | /gridappsd/debug-scripts. Do this by uncomment the following 2 lines: 9 | ````yaml 10 | # volumes: 11 | # - ./debug-scripts:/gridappsd/debug-scripts 12 | ```` 13 | by removing the # in front of them so that it looks like 14 | ````yaml 15 | volumes: 16 | - ./debug-scripts:/gridappsd/debug-scripts 17 | ```` 18 | 2. In order for you to run a simulation from the debug scripts you must first have run a simulation 19 | within the platform. Do that before continuing. 20 | 3. Open a second command window into the running gridappsd container by using the provided 21 | gridappsd-shell.sh script from the root of this repository. 22 | 4. cd into /gridappsd/debug-scripts 23 | 5. execute list-simulations.sh to discover the simulation id and port. 24 | 6. edit the runit.sh script and modify the parameters you want to use 25 | 7. cd to /gridappsd and start the platform by executing ./run-gridappsd.sh 26 | 8. open a terminal outside the docker container. 27 | 9. run the modified runit.sh script 28 | 29 | After following the above directions you should have 3 different terminals with the 3 different 30 | applications running in them. To stop them use the ./stop-debug.sh script from the terminal outside 31 | of the docker container itself. 32 | 33 | **Note the different processes have their standard out and standard error teed to the output folder** 34 | **inside the debug-scripts directory** -------------------------------------------------------------------------------- /debug-scripts/goss_sender.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import json 3 | import logging 4 | import sys 5 | import time 6 | 7 | from gridappsd import GridAPPSD, DifferenceBuilder, utils 8 | from gridappsd.topics import fncs_input_topic, fncs_output_topic 9 | 10 | 11 | def _main(): 12 | parser = argparse.ArgumentParser() 13 | parser.add_argument("simulation_id", 14 | help="Simulation id to use for responses on the message bus.") 15 | opts = parser.parse_args() 16 | gapps = GridAPPSD(opts.simulation_id, address=utils.get_gridappsd_address(), 17 | username=utils.get_gridappsd_user(), password=utils.get_gridappsd_pass()) 18 | x = input("Press Enter to continue...") 19 | message = {'command' : 'StartSimulation'} 20 | print(fncs_input_topic(opts.simulation_id)) 21 | print(json.dumps(message)) 22 | gapps.send(fncs_input_topic(opts.simulation_id), json.dumps(message)) 23 | while True: 24 | sleep(0.1) 25 | 26 | 27 | if __name__ == "__main__": 28 | _main() 29 | -------------------------------------------------------------------------------- /debug-scripts/list-simulations.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | grep -H "option \"transport:hostname*" /tmp/gridappsd_tmp/*/model_startup.glm | awk -F"/" '{print $4, $NF}' 4 | #find /tmp/gridappsd_tmp -name "option \"transport:hostname*" 5 | #ls -la /tmp/gridappsd_tmp 6 | 7 | 8 | -------------------------------------------------------------------------------- /debug-scripts/python_listener.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import json 3 | from fncs import fncs 4 | 5 | class PythonListener(object): 6 | def __init__(self, broker_port, sim_id, sim_length): 7 | self.broker_location = "tcp://localhost:{}".format(broker_port) 8 | self.subscription_topic = "{}/fncs_output".format(sim_id) 9 | self.sim_length = int(sim_length) 10 | self.sim_id = str(sim_id) 11 | 12 | 13 | def register_with_fncs(self): 14 | fncs_configuration = { 15 | "name" : "PythonListener{}".format(self.sim_id), 16 | "time_delta" : "1s", 17 | "broker" : self.broker_location, 18 | "values" : { 19 | "{}".format(self.sim_id) : { 20 | "topic" : self.subscription_topic, 21 | "default" : "{}", 22 | "type" : "JSON", 23 | "list" : "false" 24 | } 25 | } 26 | } 27 | configuration_zpl = ('name = {0}\n'.format(fncs_configuration['name']) 28 | + 'time_delta = {0}\n'.format(fncs_configuration['time_delta']) 29 | + 'broker = {0}\nvalues'.format(fncs_configuration['broker'])) 30 | for x in fncs_configuration['values'].keys(): 31 | configuration_zpl += '\n {0}'.format(x) 32 | configuration_zpl += '\n topic = {0}'.format( 33 | fncs_configuration['values'][x]['topic']) 34 | configuration_zpl += '\n default = {0}'.format( 35 | fncs_configuration['values'][x]['default']) 36 | configuration_zpl += '\n type = {0}'.format( 37 | fncs_configuration['values'][x]['type']) 38 | configuration_zpl += '\n list = {0}'.format( 39 | fncs_configuration['values'][x]['list']) 40 | try: 41 | fncs.initialize(configuration_zpl) 42 | if not fncs.is_initialized(): 43 | raise RuntimeError("fncs.initialize(configuration_zpl) failed!\nconfiguration_zpl = {}".format(configuration_zpl)) 44 | except Exception as e: 45 | if fncs.is_initialized(): 46 | fncs.die() 47 | raise 48 | 49 | 50 | def run_simulation(self): 51 | try: 52 | current_time = 0 53 | while current_time <= self.sim_length: 54 | sim_message_topics = fncs.get_events() 55 | if self.sim_id in sim_message_topics: 56 | message = fncs.get_value(self.sim_id) 57 | time_request = current_time + 1 58 | if time_request > self.sim_length: 59 | fncs.finalize() 60 | break 61 | time_approved = fncs.time_request(time_request) 62 | if time_approved != time_request: 63 | raise RuntimeError("The time approved from the fncs broker is not the time requested.\ntime_request = {}.\ntime_approved = {}".format(time_request, time_approved)) 64 | current_time += 1 65 | except Exception as e: 66 | if fncs.is_initialized(): 67 | fncs.die() 68 | raise 69 | 70 | 71 | def get_opts(): 72 | parser = argparse.ArgumentParser() 73 | parser.add_argument("broker_port", help="The port location for the FNCS broker.") 74 | parser.add_argument("simulation_id", help="The simulation id.") 75 | parser.add_argument("simulation_duration", help="The simulation runtime lenght.") 76 | opts = parser.parse_args() 77 | return opts 78 | 79 | 80 | def main(broker_port, simulation_id, simulation_duration): 81 | listener = PythonListener(broker_port, simulation_id, simulation_duration) 82 | listener.register_with_fncs() 83 | listener.run_simulation() 84 | 85 | 86 | if __name__ == "__main__": 87 | opts = get_opts() 88 | port = opts.broker_port 89 | sim_id = opts.simulation_id 90 | duration = opts.simulation_duration 91 | main(port, sim_id, duration) 92 | -------------------------------------------------------------------------------- /debug-scripts/run-fncs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ $# != 2 ]]; then 4 | echo " 5 | ERROR 6 | Invalid number of parameters. 7 | simulation_id port_num 8 | "; 9 | echo "" 10 | echo "Press enter to exit terminal" 11 | read 12 | exit 1; 13 | fi 14 | 15 | # CD to where this source is running from because 16 | # we should have write permissions to this space. 17 | cd "$( dirname "${BASH_SOURCE[0]}" )" 18 | 19 | mkdir -p "output" 20 | 21 | sim_id=$1 22 | port_num=$2 23 | 24 | gridappsd_tmp="/tmp/gridappsd_tmp/${sim_id}" 25 | 26 | if [[ ! -d ${gridappsd_tmp} ]]; then 27 | echo "Invalid simulation id"; 28 | ls -la "/tmp/gridappsd_tmp" 29 | exit 1; 30 | fi 31 | 32 | export FNCS_LOG_LEVEL=DEBUG1 33 | export FNCS_LOG_FILE="./${sim_id}_fncs_log.txt" 34 | export FNCS_BROKER="tcp://*:${port_num}" 35 | echo "Running fncs broker here: $FNCS_BROKER" 36 | 37 | fncs_broker 2 2>&1 | tee "output/fncs_output.txt" 38 | -------------------------------------------------------------------------------- /debug-scripts/run-fncsbridge.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ $# != 4 ]]; then 4 | echo " 5 | ERROR 6 | Invalid number of parameters. 7 | simulation_id port_num 8 | "; 9 | echo "" 10 | echo "Press enter to exit terminal" 11 | read 12 | exit 1; 13 | fi 14 | 15 | sim_id=$1 16 | port_num=$2 17 | run_realtime=$3 18 | duration=$4 19 | 20 | # CD to where this source is running from because 21 | # we should have write permissions to this space. 22 | cd "$( dirname "${BASH_SOURCE[0]}" )" 23 | 24 | mkdir -p "output" 25 | 26 | sim_id=$1 27 | port_num=$2 28 | 29 | gridappsd_tmp="/tmp/gridappsd_tmp/${sim_id}" 30 | 31 | if [[ ! -d ${gridappsd_tmp} ]]; then 32 | echo "Invalid simulation id"; 33 | ls -la "/tmp/gridappsd_tmp" 34 | echo "Press enter to exit" 35 | read 36 | exit 1; 37 | fi 38 | 39 | export FNCS_LOG_LEVEL=DEBUG1 40 | export FNCS_LOG_FILE="/gridappsd/debug-scripts/output/${sim_id}_fncs_log.txt" 41 | #export FNCS_BROKER="tcp://*:${port_num}" 42 | #echo $FNCS_BROKER 43 | cd /gridappsd/services/fncsgossbridge/service 44 | python fncs_goss_bridge.py ${sim_id} "tcp://127.0.0.1:${port_num}" "/tmp/gridappsd_tmp/${sim_id}/" "{\"simulation_config\":{\"run_realtime\":${run_realtime},\"duration\":${duration}}}" 2>&1 | tee "/gridappsd/debug-scripts/output/fncsgossbridge_out.txt" 45 | 46 | 47 | -------------------------------------------------------------------------------- /debug-scripts/run-goss_sender.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ $# != 1 ]]; then 4 | echo " 5 | ERROR 6 | Invalid number of parameters. 7 | simulation_id 8 | "; 9 | echo "" 10 | echo "Press enter to exit terminal" 11 | read 12 | exit 1; 13 | fi 14 | 15 | sim_id=$1 16 | 17 | cd /gridappsd/debug-scripts 18 | python3 goss_sender.py ${sim_id} 19 | -------------------------------------------------------------------------------- /debug-scripts/run-gridlabd.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ $# != 1 ]]; then 4 | echo " 5 | ERROR 6 | Invalid number of parameters. 7 | simulation_id 8 | "; 9 | echo "" 10 | echo "Press enter to exit terminal" 11 | read 12 | exit 1; 13 | fi 14 | 15 | sim_id=$1 16 | 17 | # CD to where this source is running from because 18 | # we should have write permissions to this space. 19 | cd "$( dirname "${BASH_SOURCE[0]}" )" 20 | 21 | mkdir -p "output" 22 | 23 | cd /tmp/gridappsd_tmp/${sim_id} 24 | 25 | echo "Running gridlabd here" 26 | gridlabd.sh "model_startup.glm" 2>&1 | tee "/gridappsd/debug-scripts/output/gridlabd_out.txt" 27 | -------------------------------------------------------------------------------- /debug-scripts/runit.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # simulation_id port run_realtime duration 3 | ./start-debug.sh 1793959295 49426 0 200 4 | -------------------------------------------------------------------------------- /debug-scripts/start-debug.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | if [[ $# != 4 ]]; then 5 | echo " 6 | ERROR 7 | Invalid number of parameters. 8 | simulation_id port_num run_realtime duration 9 | "; 10 | exit 1; 11 | fi 12 | 13 | sim_id=$1 14 | port_num=$2 15 | run_realtime=$3 16 | duration=$4 17 | 18 | echo "Starting fncs" 19 | x-terminal-emulator -e "docker exec -it gridappsddocker_gridappsd_1 /gridappsd/debug-scripts/run-fncs.sh ${sim_id} ${port_num}" 20 | sleep 2 21 | echo "Starting gridlabd" 22 | x-terminal-emulator -e "docker exec -it gridappsddocker_gridappsd_1 /gridappsd/debug-scripts/run-gridlabd.sh ${sim_id}" 23 | sleep 2 24 | echo "starting fncsbridge" 25 | x-terminal-emulator -e "docker exec -it gridappsddocker_gridappsd_1 /gridappsd/debug-scripts/run-fncsbridge.sh ${sim_id} ${port_num} ${run_realtime} ${duration}" 26 | sleep 2 27 | echo "starting goss_sender" 28 | x-terminal-emulator -e "docker exec -it gridappsddocker_gridappsd_1 /gridappsd/debug-scripts/run-goss_sender.sh ${sim_id}" 29 | -------------------------------------------------------------------------------- /debug-scripts/stop-debug.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker exec -it gridappsddocker_gridappsd_1 pkill fncs_broker 4 | docker exec -it gridappsddocker_gridappsd_1 pkill python 5 | docker exec -it gridappsddocker_gridappsd_1 pkill bash 6 | echo "" -------------------------------------------------------------------------------- /docker-compose.d/docker-compose_der-dispatch.yml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | services: 4 | derdispatch: 5 | image: gridappsd/der-dispatch-app 6 | ports: 7 | - 9001:9001 8 | environment: 9 | GRIDAPPSD_URI: tcp://gridappsd:61613 10 | depends_on: 11 | - gridappsd 12 | 13 | -------------------------------------------------------------------------------- /docker-compose.d/docker-compose_grid-forecasting.yml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | services: 4 | grid_forecasting: 5 | image: gridappsd/grid-forecasting-app 6 | ports: 7 | - 9003:9003 8 | environment: 9 | GRIDAPPSD_URI: tcp://gridappsd:61613 10 | depends_on: 11 | - gridappsd 12 | #volumes: 13 | #- /home/martin/gridappsd-docker/Grid-Forecasting-Public:/usr/src/gridappsd-grid-forecasting 14 | -------------------------------------------------------------------------------- /docker-compose.d/docker-compose_pyvvo.yml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | services: 4 | pyvvo: 5 | image: gridappsd/pyvvo:latest 6 | environment: 7 | # PyVVO uses a flag to determine if it's being managed by the platform or not. 8 | platform: "1" 9 | # PyVVO needs to know how to access the database. 10 | DB_HOST: "pyvvo-db" 11 | DB_USER: "pyvvo" 12 | DB_PASS: "pyvvo" 13 | DB_DB: "pyvvo" 14 | DB_PORT: "3306" 15 | # So that our imports work we need to patch the PYTHONPATH 16 | PYTHONPATH: ":/pyvvo/pyvvo" 17 | # The following is/are needed for app-container-base which PyVVO is built on. 18 | GRIDAPPSD_URI: tcp://gridappsd:61613 19 | # The following are defined in the Dockerfile for gridappsd-python, so this 20 | # is redundent. 21 | GRIDAPPSD_USER: system 22 | GRIDAPPSD_PASS: manager 23 | depends_on: 24 | - gridappsd 25 | - pyvvo-db 26 | volumes: 27 | # Map the main configuration file. 28 | - ./conf/pyvvo_config.json:/pyvvo/pyvvo/pyvvo/pyvvo_config.json 29 | # Map the application code (to avoid having to rebuild while developing). 30 | # This should not be present for "production" 31 | # - /home/martin/git/pyvvo/pyvvo:/pyvvo/pyvvo/pyvvo 32 | 33 | pyvvo-db: 34 | image: gridappsd/pyvvo:mysql-latest 35 | volumes: 36 | - db_volume:/var/lib/mysql 37 | environment: 38 | MYSQL_RANDOM_ROOT_PASSWORD: 'yes' 39 | MYSQL_DATABASE: 'pyvvo' 40 | MYSQL_USER: 'pyvvo' 41 | MYSQL_PASSWORD: 'pyvvo' 42 | expose: 43 | - "3306" 44 | 45 | volumes: 46 | db_volume: {} 47 | -------------------------------------------------------------------------------- /docker-compose.d/docker-compose_solar-forecast.yml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | services: 4 | solar_forecast: 5 | image: gridappsd/solar-forecast-app 6 | ports: 7 | - 9002:9002 8 | environment: 9 | GRIDAPPSD_URI: tcp://gridappsd:61613 10 | depends_on: 11 | - gridappsd 12 | -------------------------------------------------------------------------------- /docker-compose.d/docker-compose_wsu-restoration.yml.cplex: -------------------------------------------------------------------------------- 1 | 2 | 3 | services: 4 | wsu_restoration: 5 | image: gridappsd/wsu-restoration-app 6 | volumes: 7 | - /opt/ibm/ILOG/CPLEX_Studio1261/:/opt/ibm/ILOG/CPLEX_Studio1261/ 8 | environment: 9 | GRIDAPPSD_URI: tcp://gridappsd:61613 10 | depends_on: 11 | - gridappsd 12 | -------------------------------------------------------------------------------- /docker-compose.d/docker-compose_wsu-vvo.yml.dist: -------------------------------------------------------------------------------- 1 | 2 | services: 3 | wsu_vvo: 4 | image: gridappsd/wsu-vvo-app 5 | depends_on: 6 | - gridappsd 7 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | sample_app: 3 | image: gridappsd/sample_app${GRIDAPPSD_TAG} 4 | container_name: sample_app 5 | environment: 6 | GRIDAPPSD_URI: tcp://gridappsd:61613 7 | # GRIDAPPSD_USER: system 8 | # GRIDAPPSD_PASS: manager 9 | depends_on: 10 | - gridappsd 11 | #volumes: 12 | # Change upto the : where you have your git repository on your 13 | # computer. The : delinates between the host (your computer) and 14 | # the container (inside of the container) 15 | # 16 | # In order for the app to be registered with gridappsd a configuration 17 | # file must be mounted or copied to /appconfig 18 | # - $HOME/git/gridappsd-sample-app/sample_app.config:/appconfig 19 | 20 | # When debugging apps it is helpful to mount the application over the 21 | # top of where it normally be ran so that changes on the host are immediately 22 | # reflected inside the container. 23 | # 24 | #- $HOME/git/gridappsd-sample-app/:/usr/src/gridappsd-sample 25 | 26 | blazegraph: 27 | image: gridappsd/blazegraph${GRIDAPPSD_TAG} 28 | container_name: blazegraph 29 | ports: 30 | - 8889:8080 31 | 32 | redis: 33 | image: redis:3.2.11-alpine 34 | container_name: redis 35 | ports: 36 | - 6379:6379 37 | 38 | volumes: 39 | - ./gridappsd/redis/data:/data 40 | entrypoint: redis-server --appendonly yes 41 | 42 | mysql: 43 | image: mysql/mysql-server:5.7 44 | container_name: mysql 45 | ports: 46 | - 3306:3306 47 | 48 | environment: 49 | MYSQL_RANDOM_ROOT_PASSWORD: "yes" 50 | MYSQL_PORT: 3306 51 | 52 | volumes: 53 | - ./gridappsd/mysql:/var/lib/mysql 54 | - ./dumps/gridappsd_mysql_dump.sql:/docker-entrypoint-initdb.d/schema.sql:ro 55 | 56 | viz: 57 | image: gridappsd/viz${GRIDAPPSD_TAG} 58 | container_name: viz 59 | ports: 60 | - 8080:8082 61 | depends_on: 62 | - gridappsd 63 | 64 | gridappsd: 65 | image: gridappsd/gridappsd${GRIDAPPSD_TAG} 66 | container_name: gridappsd 67 | ports: 68 | # Each of the following are port mappings from the host into the 69 | # container. The first three are used by GridAPPS-D for the different 70 | # protocols. 71 | - 61613:61613 72 | - 61614:61614 73 | - 61616:61616 74 | - 20000-20020:20000-20020 75 | # Uncomment to allow debugging on this port 76 | - 8000:8000 77 | # Add debugging to your application via the following port 78 | - 8888:8888 79 | 80 | working_dir: /gridappsd 81 | environment: 82 | - PATH=/home/gridappsd/.local/bin:/gridappsd/bin:/gridappsd/lib:/gridappsd/services/fncsgossbridge/service:/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin 83 | - LD_LIBRARY_PATH=/usr/local/lib64 84 | # Start the platform on boot 85 | - AUTOSTART=0 86 | # X11 application support--use same display as host, typically ":0" 87 | # - DISPLAY=${DISPLAY} 88 | # Debugging is only necessary if you intend to remote debug the GridAPPS-D process iself. 89 | # Turning this on will allow the user to remote debug the gridappsd server on port 8000. 90 | - DEBUG=1 91 | # volumes: 92 | # X11 application support--share X11 port with container host 93 | # - /tmp/.X11-unix:/tmp/.X11-unix 94 | # The following allow applications to be mounted into the container so that 95 | # gridappsd can start them in the correct context. 96 | # 97 | # The format is local_path:container_path where local_path is on the host machine and the 98 | # container_dir is inside the container. The paths can be either a file or a directory. In 99 | # order for gridappsd to recognize it as an application the container path must be inside 100 | # the /gridappsd/applications. For services the container path must be inside /gridappsd/services. 101 | # 102 | # The following assumes you have cloned/downloaded the sample app in a sibling folder of this 103 | # repository. Once uncommenting the three lines below the sample_app will be available in the 104 | # container 105 | # 106 | # volumes: 107 | # - ~/git/gridappsd-sample-app/sample_app:/gridappsd/applications/sample_app 108 | # - ~/git/gridappsd-sample-app/sample_app/sample_app.config:/gridappsd/applications/sample_app.config 109 | # volumes: 110 | # - ./debug-scripts:/gridappsd/debug-scripts 111 | depends_on: 112 | - mysql 113 | - blazegraph 114 | - redis 115 | 116 | proven: 117 | image: gridappsd/proven${GRIDAPPSD_TAG} 118 | container_name: proven 119 | ports: 120 | - 18080:8080 121 | environment: 122 | # PROVEN_SERVICES_PORT - Proven service port [18080] 123 | # PROVEN_SWAGGER_HOST_PORT - Host and port value for Swagger (:) 124 | # PROVEN_USE_IDB - Use InfluxDB to save provenance metrics (true | false) [false] 125 | # PROVEN_IDB_URL - InfluxDB URL [http://localhost:8086] 126 | # PROVEN_IDB_DB - InfluxDB Database [proven] 127 | # PROVEN_IDB_RP - InfluxDB retention policy [autogen] 128 | # PROVEN_IDB_USERNAME - InfluxDb username [root] 129 | # PROVEN_IDB_PASSWORD - InfluxDb password [root] 130 | # PROVEN_T3DIR - directory location of triple store [user_home_directory] 131 | #### 132 | - PROVEN_SERVICES_PORT=18080 133 | - PROVEN_SWAGGER_HOST_PORT=localhost:18080 134 | - PROVEN_USE_IDB=true 135 | - PROVEN_IDB_URL=http://influxdb:8086 136 | - PROVEN_IDB_DB=proven 137 | - PROVEN_IDB_RP=autogen 138 | - PROVEN_IDB_USERNAME=root 139 | - PROVEN_IDB_PASSWORD=root 140 | - PROVEN_T3DIR=/proven 141 | 142 | influxdb: 143 | image: gridappsd/influxdb${GRIDAPPSD_TAG} 144 | container_name: influxdb 145 | environment: 146 | INFLUXDB_DB: "proven" 147 | ports: 148 | - 8086:8086 149 | 150 | -------------------------------------------------------------------------------- /docker_install_ubuntu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Environment variables you need to set so you don't have to edit the script below. 4 | DOCKER_CHANNEL=stable 5 | DOCKER_COMPOSE_VERSION=2.26.0 6 | 7 | # Update the apt package index. 8 | sudo apt-get update 9 | 10 | # Install packages to allow apt to use a repository over HTTPS. 11 | sudo apt-get install -y \ 12 | apt-transport-https \ 13 | ca-certificates \ 14 | curl \ 15 | software-properties-common \ 16 | vim 17 | 18 | # Add Docker's official GPG key. 19 | curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add - 20 | 21 | # Verify the fingerprint. 22 | sudo apt-key fingerprint 0EBFCD88 23 | 24 | # Pick the release channel. 25 | sudo add-apt-repository \ 26 | "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \ 27 | $(lsb_release -cs) \ 28 | ${DOCKER_CHANNEL}" 29 | 30 | # Update the apt package index. 31 | sudo apt-get update 32 | 33 | # Install the latest version of Docker CE. 34 | sudo apt-get install -y docker-ce 35 | 36 | # Allow your user to access the Docker CLI without needing root. 37 | sudo /usr/sbin/usermod -aG docker $USER 38 | 39 | # Install Docker Compose. 40 | curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` -o /tmp/docker-compose 41 | sudo mv /tmp/docker-compose /usr/local/bin/docker-compose 42 | sudo chmod +x /usr/local/bin/docker-compose 43 | sudo chown root:root /usr/local/bin/docker-compose 44 | -------------------------------------------------------------------------------- /gridappsd-shell: -------------------------------------------------------------------------------- 1 | 2 | if [ $# -eq 1 ]; then 3 | docker exec -u $1 -it gridappsd /bin/bash 4 | else 5 | docker exec -it gridappsd /bin/bash 6 | fi 7 | 8 | -------------------------------------------------------------------------------- /remove_containers.sh: -------------------------------------------------------------------------------- 1 | docker rm $(docker ps -a -q) 2 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | usage () { 4 | /bin/echo "Usage: $0 [-d] [-p] [-r [ip address]] [-t tag]" 5 | /bin/echo " -d debug" 6 | /bin/echo " -p pull updated containers" 7 | /bin/echo " -r use remote ip address for viz, will use external ip if no address is supplied" 8 | /bin/echo " -t tag specify gridappsd docker tag" 9 | exit 2 10 | } 11 | 12 | create_env () { 13 | if [ -f '.env' ]; then 14 | prevtag=`grep GRIDAPPSD_TAG .env | sed 's/GRIDAPPSD_TAG=://'` 15 | currtag=`echo $GRIDAPPSD_TAG | sed 's/://'` 16 | if [ "$prevtag" != "$currtag" ]; then 17 | echo " " 18 | echo "Error changing tag from $prevtag to $currtag" 19 | echo "Please run the stop.sh script with the -c option to remove " 20 | echo "your existing containers before changing tags" 21 | echo " ./stop.sh -c" 22 | echo " " 23 | echo "Exiting " 24 | echo " " 25 | #echo "Please remove previous versions by runing ./stop.sh -c" 26 | exit 1 27 | fi 28 | else 29 | echo " " 30 | echo "Create the docker env file with the tag variables" 31 | # Create the docker env file with the tag variables 32 | cat > .env << EOF 33 | # This file is auto generated, please change the tag with the run.sh -t option 34 | GRIDAPPSD_TAG=$GRIDAPPSD_TAG 35 | EOF 36 | fi 37 | } 38 | 39 | configure_viz () { 40 | echo " " 41 | echo "Configuring remote viz $remote_ip" 42 | url_viz="http://${remote_ip}:8080/" 43 | 44 | if [[ $remote_ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then 45 | cat > conf/viz.config << EOF 46 | { 47 | "version": "remote$GRIDAPPSD_TAG", 48 | "host": "$remote_ip:61614" 49 | } 50 | EOF 51 | 52 | cat > docker-compose.d/viz.yml << EOF 53 | version: '2' 54 | 55 | services: 56 | viz: 57 | volumes: 58 | - ./conf/viz.config:/gridappsd/viz/assets/config.json 59 | EOF 60 | 61 | else 62 | echo "Error getting remote ip address" 63 | exit 1 64 | fi 65 | } 66 | 67 | debug_msg() { 68 | msg=$1 69 | if [ $debug == 1 ]; then 70 | now=`date` 71 | echo "DEBUG : $now : $msg" 72 | fi 73 | } 74 | 75 | pull_containers() { 76 | echo " " 77 | echo "Pulling updated containers" 78 | docker-compose $compose_files pull --ignore-pull-failures 79 | } 80 | 81 | http_status_container() { 82 | cnt=$1 83 | 84 | echo " " 85 | echo "Getting $cnt status" 86 | if [ "$cnt" == "blazegraph" ]; then 87 | url=$url_blazegraph 88 | elif [ "$cnt" == "viz" ]; then 89 | url=$url_viz 90 | fi 91 | debug_msg "$cnt $url" 92 | status="0" 93 | count=0 94 | maxcount=60 95 | while [ $status -ne "200" -a $count -lt $maxcount ] 96 | do 97 | status=$(curl -s --head -w %{http_code} "$url" -o /dev/null) 98 | debug_msg "curl status: $status" 99 | sleep 1 100 | count=`expr $count + 1` 101 | done 102 | 103 | debug_msg "tried $url $count times, max is $maxcount" 104 | if [ $count -ge $maxcount ]; then 105 | echo "Error contacting $url ($status)" 106 | echo "Exiting " 107 | echo " " 108 | exit 1 109 | fi 110 | } 111 | 112 | url_viz="http://localhost:8080/" 113 | url_blazegraph="http://localhost:8889/bigdata/namespace/kb/" 114 | mysql_file="gridappsd_mysql_dump.sql" 115 | data_dir="dumps" 116 | debug=0 117 | exists=0 118 | remote_ip='' 119 | # set the default tag for the gridappsd and viz containers 120 | GRIDAPPSD_TAG=':v2023.07.0' 121 | 122 | # parse options 123 | while getopts dprt: option ; do 124 | case $option in 125 | d) # enable debug output 126 | debug=1 127 | ;; 128 | p) # pull updated containers 129 | pull_containers 130 | exit 0 131 | ;; 132 | r) # Remote ip address 133 | eval nextopt=\${$OPTIND} 134 | if [[ -n $nextopt && $nextopt != -* ]]; then 135 | OPTIND=$((OPTIND +1)) 136 | remote_ip="$nextopt" 137 | else 138 | remote_ip=$( curl -s ifconfig.me ) 139 | fi 140 | ;; 141 | t) # Pass gridappsd tag to docker-compose 142 | GRIDAPPSD_TAG=":$OPTARG" 143 | ;; 144 | *) # Print Usage 145 | usage 146 | ;; 147 | esac 148 | done 149 | shift `expr $OPTIND - 1` 150 | 151 | [ -f '.env' ] && exists=1 152 | create_env 153 | [ ! -z "$remote_ip" ] && configure_viz 154 | 155 | compose_files=$( ls -1 docker-compose.d/*yml 2>/dev/null | sed -e 's/^/-f /g' | tr '\n' ' ' ) 156 | compose_files="-f docker-compose.yml $compose_files" 157 | echo "Compose files: $compose_files" 158 | 159 | 160 | # Mysql 161 | [ ! -d "$data_dir" ] && mkdir "$data_dir" 162 | if [ ! -f "$data_dir/$mysql_file" ]; then 163 | echo " " 164 | echo "Downloading mysql data" 165 | debug_msg "curl -s -o \"$data_dir/$mysql_file\" \"https://raw.githubusercontent.com/GRIDAPPSD/Bootstrap/master/$mysql_file\"" 166 | curl -s -o "$data_dir/$mysql_file" "https://raw.githubusercontent.com/GRIDAPPSD/Bootstrap/master/$mysql_file" 167 | if [ -f $data_dir/$mysql_file ]; then 168 | sed -i'.bak' -e "s/'gridappsd'@'localhost'/'gridappsd'@'%'/g" $data_dir/$mysql_file 169 | # clean up 170 | rm $data_dir/${mysql_file}.bak 171 | else 172 | echo "Error downloading $data_dir/$mysql_file" 173 | echo "Exiting " 174 | echo " " 175 | exit 1 176 | fi 177 | fi 178 | 179 | echo " " 180 | echo "Getting blazegraph status" 181 | status=$(curl -s --head -w %{http_code} "$url_blazegraph" -o /dev/null) 182 | debug_msg "blazegraph curl status: $status" 183 | 184 | #if [ $GRIDAPPSD_TAG == ':develop' ]; then 185 | pull_containers 186 | #fi 187 | 188 | echo " " 189 | echo "Starting the docker containers" 190 | echo " " 191 | echo " " 192 | docker-compose $compose_files up -d 193 | container_status=$? 194 | 195 | if [ $container_status -ne 0 ]; then 196 | echo " " 197 | echo "Error starting containers" 198 | echo "Exiting " 199 | echo " " 200 | exit 1 201 | fi 202 | 203 | http_status_container 'blazegraph' 204 | 205 | # sleep just a little longer to make sure blazegraph is ready to receive data. 206 | sleep 3 207 | 208 | bz_load_status=0 209 | echo " " 210 | echo "Checking blazegraph data" 211 | 212 | echo " " 213 | # Check if blazegraph data is already loaded 214 | rangeCount=`curl -s -G -H 'Accept: application/xml' "${url_blazegraph}sparql" --data-urlencode ESTCARD | sed 's/.*rangeCount=\"\([0-9]*\)\".*/\1/'` 215 | echo "Blazegrpah data available ($rangeCount)" 216 | 217 | http_status_container 'viz' 218 | 219 | # echo " " 220 | # echo "Opening web browser to the viz container $url_viz" 221 | # if [ `uname` == "Linux" ]; then 222 | # xdg-open $url_viz 223 | # elif [ `uname` == "Darwin" ]; then 224 | # open $url_viz 225 | # else 226 | # echo " " 227 | # echo "Please open a browser to $url_viz" 228 | # fi 229 | 230 | echo " " 231 | echo "Containers are running" 232 | 233 | echo "$url_viz" 234 | 235 | if tty -s ; then 236 | gridappsd_container=`docker inspect --format="{{.Name}}" \`docker-compose $compose_files ps -q gridappsd\` | sed 's:/::'` 237 | 238 | echo " " 239 | echo "Connecting to the gridappsd container" 240 | echo "docker exec -it $gridappsd_container /bin/bash" 241 | echo " " 242 | docker exec -it $gridappsd_container /bin/bash 243 | fi 244 | 245 | exit 0 246 | -------------------------------------------------------------------------------- /stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | usage () { 6 | /bin/echo "Usage: $0 [-c|w]" 7 | /bin/echo " -c remove containers and downloaded dump files and mysql database" 8 | /bin/echo " -w remove containers and mysql database, preserve downloaded dump files" 9 | exit 2 10 | } 11 | 12 | clean_up () { 13 | echo " " 14 | echo "Removing docker containers" 15 | docker-compose $compose_files down 16 | 17 | # remove the dump files if -c option 18 | if [ $cleanup -eq 1 ]; then 19 | 20 | if [ -f $data_dir/$mysql_file ] ; then 21 | echo " " 22 | echo "Removing mysql dump file" 23 | rm "$data_dir/$mysql_file" 24 | fi 25 | 26 | # download may sometimes fail and create a directory 27 | if [ -d $data_dir/$mysql_file ] ; then 28 | echo " " 29 | echo "Removing mysql dump file" 30 | rmdir "$data_dir/$mysql_file" 31 | fi 32 | 33 | for blazegraph_file in $blazegraph_models; do 34 | if [ -f $data_dir/$blazegraph_file ] ; then 35 | echo " " 36 | echo "Removing blazegraph import file $blazegraph_file" 37 | rm "$data_dir/$blazegraph_file" 38 | fi 39 | # download may sometimes fail and create a directory 40 | if [ -d $data_dir/$blazegraph_file ] ; then 41 | echo " " 42 | echo "Removing blazegraph import file $blazegraph_file" 43 | rmdir "$data_dir/$blazegraph_file" 44 | fi 45 | done 46 | fi 47 | 48 | if [ -f .env ] ; then 49 | echo " " 50 | echo "Removing the docker .env file" 51 | rm .env 52 | fi 53 | 54 | if [ -f conf/viz.config ] ; then 55 | echo " " 56 | echo "Removing the remote viz configuration file" 57 | rm conf/viz.config 58 | fi 59 | 60 | if [ -f docker-compose.d/viz.yml ] ; then 61 | echo " " 62 | echo "Removing the remote viz compose file" 63 | rm docker-compose.d/viz.yml 64 | fi 65 | 66 | for dbdir in $database_dirs; do 67 | if [ -d $dbdir ] ; then 68 | echo " " 69 | if [ -O $dbdir ] ; then 70 | echo "Removing $dbdir database files" 71 | rm -r $dbdir 72 | else 73 | echo "Error: unable to remove $dbdir, please run the following command." 74 | echo "sudo rm -r $dbdir" 75 | fi 76 | fi 77 | done 78 | } 79 | 80 | blazegraph_models="EPRI_DPV_J1.xml IEEE123.xml R2_12_47_2.xml IEEE8500.xml ieee8500.xml" 81 | mysql_file="gridappsd_mysql_dump.sql" 82 | data_dir="dumps" 83 | cleanup=0 84 | database_dirs="gridappsdmysql gridappsd" 85 | 86 | compose_files=$( ls -1 docker-compose.d/*yml 2>/dev/null | sed -e 's/^/-f /g' | tr '\n' ' ' ) 87 | compose_files="-f docker-compose.yml $compose_files" 88 | echo "Compose files: $compose_files" 89 | 90 | # parse options 91 | while getopts cw option ; do 92 | case $option in 93 | c) # Cleanup downloads and containers and dump files 94 | cleanup=1 95 | ;; 96 | w) # Cleanup downloads and containers 97 | cleanup=2 98 | ;; 99 | *) # Print Usage 100 | usage 101 | ;; 102 | esac 103 | done 104 | shift `expr $OPTIND - 1` 105 | 106 | echo " " 107 | echo "Shutting down the docker containers" 108 | docker-compose $compose_files stop 109 | 110 | if [ $cleanup -gt 0 ]; then 111 | clean_up 112 | fi 113 | 114 | echo " " 115 | 116 | exit 0 117 | --------------------------------------------------------------------------------