## OpenADR Virtual Top Node ##

The open-source OpenADR (OADR) Virtual Top Node software was developed to provide the electric power industry with an open-source research tool to demonstrate and test OpenADR 2.0 and to provide utilities with a tool to research the potential use of OpenADR 2.0 in different use cases. This server application is one example of how the OpenADR 2.0 specification can be applied. It includes a graphical user interface for setting up user accounts, assigning clients (virtual end nodes, or VENs), defining resources, selecting market contexts, and creating and scheduling demand response events. EPRI’s OADR VTN was developed and tested on an Ubuntu 14.04 desktop and server. Limited testing has been done on OS X. The software has not been tested on Windows Server, though all of the software used to run the OADR VTN runs on Windows. This user manual describes how to install and use EPRI’s open-source OpenADR VTN application.

## Documentation/Help ##
Please refer to the [Software Manual](https://github.com/epri-dev/OpenADR-Virtual-Top-Node/releases "Software Manual") in the release section for technical documentation.

## Notice
The EPRI OpenADR 2.0 Virtual Top Node (VTN) and VEN was designed with the advanced software that was available at that time. This software, like any others, has dependencies on third-party software packages. Some of these third-party software packages are deprecated.

Since its release in 2014, EPRI’s OpenADR 2.0 VTN has been downloaded over 6,700 times, supported numerous utility demonstration and field projects across the world, and has been implemented in commercial solutions. While EPRI has decided to discontinue support for the current version of EPRI OpenADR VTN due to deprecated software packages offered by the third parties, the code will remain on EPRI’s GitHub page as an example for others who are interested in seeing an example implementation. EPRI will continue to explore how to continue support to such software tools.

## Installing via Docker

### Docker install

These instructions are for a Ubuntu 16.04.6 LTS x64 machine. First install Docker CE:
```
apt-get update
apt-get dist-upgrade
apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
curl -s https://download.docker.com/linux/ubuntu/gpg | apt-key add -
apt-get update
apt-get install docker-ce
curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
```

### Repo setup
Now clone this repo to `/root/epri-vtn_custom`. Install the following files:

* `/root/epri-vtn_custom/.env` Environment variables for docker-compose, use `example.env` as a starting place and be sure to change `RAILS_SECRET_TOKEN`.
* `/root/epri-vtn_custom/ssl.crt` VTN certificate file in PEM format. This will be the concatenated result of 3 certificates: 1) VTN cert `TEST_RSA_VTN_2003XXXXXXXXX_cert.pem`, 2) Root Cert Authority `TEST_OpenADR_RSA_RCA0002_Cert.pem`, 3) Service Provider `TEST_OpenADR_RSA_SPCA0002_Cert.pem`. Certificates must be present in that order.
* `/root/epri-vtn_custom/ssl.key` VTN key file in PEM format. This will come from a file that looks like `TEST_RSA_VTN_2003XXXXXXXXX_privkey.pem`.

### Provision database
This step needs to be ran on a fresh database. Once it has been ran there will be no need to re-provision the database again even if EPRI is updated.

Edit `docker-compose.yml` and uncomment the `# command: initdb` line. Now run

```
docker-compose up --build
```

And you should see a message `initdb finished successfully`. When you see that you can Ctrl-C to kill the session and comment out the `command: initdb` line.

### Run EPRI
Ensure `command: initdb` is commented out. Run

```
docker-compose up --build -d
```

You should now be able to access `https://ipaddress/` from your web browser.
