Skip to content

Commit

Permalink
♻️ Working!! Almost final upgrade and refactor of the demo
Browse files Browse the repository at this point in the history
Summary of changes:
- Switch to using pre-built images
    - This is copying over the docker-compose and modifying
      it to use images; we can and should do better
- Apply runtime patches to the CSMS
    - After changing the paths in the script to run them from the current location
- Apply change paths throughout
- Remove the second EVSE and connector so they are not created in the device model
    - Question: Is `/ext/dist/share/everest/modules/OCPP201/component_config/` now the source of truth? Will it always rewrite the DB? Is the DB then just for convenient access?
- Since we are now on debian, install patch using apt-get
- The new version is after the external payment was removed externally, so add it back using patches
- Since we can no longer copy over a DB with the CSMS value (since it will be overridden), we use `sed` to change it in the component_config
- With the new build, the build is in `/ext/build` and the distribution is in `/ext/dist` - changed paths in `demo` and the manager patches to match
- change to the new module names for the new release
- although we added back a patch to support the payment method, we are still using `ac` and `dc` in the JsEvManager, not `AC_three_phase_core`. Change the nodered flow to match.
- change the CSMS build action to prepend the csms name to the image name so that we don't create CSMS image called `manager` which overrides the everest manager

Testing done:
- `bash demo-iso15118-2-ocpp-201.sh -r $(pwd) -1` works without any additional changes

NOTE that this still needs the manager to be pushed since it is too large to be built by the CI dec0ca2

And there is still a fair amount of immediate cleanup to be
done as well. But this was getting long and complex, and I
wanted to check it in before it got too unwieldy.

Signed-off-by: Shankari <[email protected]>
  • Loading branch information
shankari committed Nov 15, 2024
1 parent 3e3b50f commit dbc2f2d
Show file tree
Hide file tree
Showing 19 changed files with 332 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TAG=0.0.16
TAG=0.0.17-localbuild

EVEREST_MANAGER_CPUS='1.0'
EVEREST_MANAGER_MEMORY='1024mb'
2 changes: 1 addition & 1 deletion .github/workflows/build_and_push_csms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.host_namespace }}/${{ matrix.image_name }}
images: ${{ matrix.host_namespace }}/${{ matrix-csms }}-${{ matrix.image_name }}
tags: |
type=semver,pattern={{version}},value=v${{ steps.docker-image-version-check.outputs.TAG }}
Expand Down
1 change: 0 additions & 1 deletion citrineos/build-and-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ exit 1

pushd Server || exit 1

docker compose build
if ! docker compose --project-name "${DEMO_CSMS}"-csms up -d --wait; then
echo "Failed to start ${DEMO_CSMS}"
exit 1
Expand Down
47 changes: 26 additions & 21 deletions demo-iso15118-2-ocpp-201.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
DEMO_REPO="https://github.com/everest/everest-demo.git"
DEMO_BRANCH="main"

MAEVE_REPO="https://github.com/louisg1337/maeve-csms.git"
# MAEVE_BRANCH="b990d0eddf2bf80be8d9524a7b08029fbb305c7d" # patch files are based on this commit
MAEVE_BRANCH="set_charging_profile"

CITRINEOS_REPO="https://github.com/citrineos/citrineos-core.git"
CITRINEOS_BRANCH="feature/everest-demo"

START_OPTION="auto"

usage="usage: $(basename "$0") [-r <repo>] [-b <branch>] [-c <csms>] [1|2|3] [-h]
Expand Down Expand Up @@ -87,8 +80,6 @@ echo "DEMO VERSION: $DEMO_VERSION"
echo "DEMO CONFIG: $DEMO_COMPOSE_FILE_NAME"
echo "DEMO DIR: $DEMO_DIR"
echo "DEMO CSMS: $DEMO_CSMS"
echo "DEMO CSMS REPO: $DEMO_CSMS_REPO"
echo "DEMO CSMS BRANCH: $DEMO_CSMS_BRANCH"


cd "${DEMO_DIR}" || exit 1
Expand All @@ -102,20 +93,23 @@ else
fi

# BEGIN: Setting up the CSMS
echo "Cloning ${DEMO_CSMS} CSMS from ${DEMO_CSMS_REPO} into ${DEMO_DIR}/${DEMO_CSMS}-csms and starting it"
git clone --branch "${DEMO_CSMS_BRANCH}" "${DEMO_CSMS_REPO}" ${DEMO_CSMS}-csms
pushd everest-demo/${DEMO_CSMS} || exit 1

pushd ${DEMO_CSMS}-csms || exit 1
# Copy over the environment variable so we can get the tag
cp ../.env .

cp ../everest-demo/manager/cached_certs_correct_name_emaid.tar.gz .
cp ../manager/cached_certs_correct_name_emaid.tar.gz .

if [[ "$DEMO_VERSION" =~ sp2 || "$DEMO_VERSION" =~ sp3 ]]; then
source ../everest-demo/${DEMO_CSMS}/copy-certs.sh
source ../${DEMO_CSMS}/copy-certs.sh
fi

source ../everest-demo/${DEMO_CSMS}/apply-patches.sh
source ../${DEMO_CSMS}/apply-runtime-patches.sh

source ../everest-demo/${DEMO_CSMS}/build-and-run.sh
if ! docker compose --project-name "${DEMO_CSMS}"-csms up -d --wait; then
echo "Failed to start ${DEMO_CSMS}"
exit 1
fi

# note that docker compose --wait only waits for the
# containers to be up, not necessarily the services in those
Expand All @@ -124,7 +118,7 @@ fi
sleep 5

echo "Adding a charger and RFID card to ${DEMO_CSMS}"
source ../everest-demo/${DEMO_CSMS}/add-charger-and-rfid-card.sh
source ../${DEMO_CSMS}/add-charger-and-rfid-card.sh

popd || exit 1
# END: Setting up the CSMS
Expand All @@ -133,18 +127,29 @@ pushd everest-demo || exit 1
echo "API calls to CSMS finished, Starting everest"
docker compose --project-name everest-ac-demo --file "${DEMO_COMPOSE_FILE_NAME}" up -d --wait
docker cp manager/config-sil-ocpp201-pnc.yaml everest-ac-demo-manager-1:/ext/source/config/config-sil-ocpp201-pnc.yaml
docker exec everest-ac-demo-manager-1 rm /ext/dist/share/everest/modules/OCPP201/component_config/custom/EVSE_2.json
docker exec everest-ac-demo-manager-1 rm /ext/dist/share/everest/modules/OCPP201/component_config/custom/Connector_2_1.json

echo "Configuring and restarting nodered"
docker cp nodered/config/config-sil-iso15118-ac-flow.json everest-ac-demo-nodered-1:/config/config-sil-two-evse-flow.json
docker restart everest-ac-demo-nodered-1

echo "Installing patch and vim and cleaning up the cache"
docker exec everest-ac-demo-manager-1 /bin/bash -c "apt-get -qq -o=Dpkg::Use-Pty=0 update \
&& apt-get install -y -qq -o=Dpkg::Use-Pty=0 patch \
&& apt-get install -y -qq -o=Dpkg::Use-Pty=0 vim \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*"

echo "Copying over EVerest patches"
docker cp manager/enable_payment_method_in_python.patch everest-ac-demo-manager-1:/tmp/
docker cp manager/support_payment_in_jsevmanager.patch everest-ac-demo-manager-1:/tmp/

echo "Now applying the patches"
docker cp manager/enable_evcc_logging.cfg everest-ac-demo-manager-1:/ext/source/build/dist/etc/everest/default_logging.cfg
docker exec everest-ac-demo-manager-1 /bin/bash -c "apk add patch"
docker cp manager/enable_evcc_logging.cfg everest-ac-demo-manager-1:/ext/dist/etc/everest/default_logging.cfg
docker exec everest-ac-demo-manager-1 /bin/bash -c "cd /ext && patch -p0 -i /tmp/enable_payment_method_in_python.patch"
docker exec everest-ac-demo-manager-1 /bin/bash -c "cd /ext/dist/libexec/everest && patch -p1 -i /tmp/support_payment_in_jsevmanager.patch"
docker exec everest-ac-demo-manager-1 /bin/bash -c "sed -i 's#ws://localhost:9000#ws://host.docker.internal/ws/cp001#' /ext/dist/share/everest/modules/OCPP201/component_config/standardized/InternalCtrlr.json"

if [[ "$DEMO_VERSION" =~ sp2 || "$DEMO_VERSION" =~ sp3 ]]; then
docker cp manager/cached_certs_correct_name_emaid.tar.gz everest-ac-demo-manager-1:/ext/source/build
Expand Down Expand Up @@ -174,10 +179,10 @@ fi

if [[ "$START_OPTION" == "auto" ]]; then
echo "Starting software in the loop simulation automatically"
docker exec everest-ac-demo-manager-1 sh /ext/source/build/run-scripts/run-sil-ocpp201-pnc.sh
docker exec everest-ac-demo-manager-1 sh /ext/build/run-scripts/run-sil-ocpp201-pnc.sh
else
echo "Please start the software in the loop simulation manually by running"
echo "on your laptop: docker exec -it everest-ac-demo-manager-1 /bin/bash"
echo "in the container: sh /ext/source/build/run-scripts/run-sil-ocpp201-pnc.sh"
echo "in the container: sh /ext/build/run-scripts/run-sil-ocpp201-pnc.sh"
echo "You can now stop and restart the manager without re-creating the container"
fi
6 changes: 3 additions & 3 deletions maeve/apply-runtime-patches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

if [[ "$DEMO_VERSION" =~ sp2 || "$DEMO_VERSION" =~ sp3 ]]; then
echo "Patching the CSMS to enable EVerest organization"
patch -p1 -i ../everest-demo/maeve/maeve-csms-everest-org.patch
patch -p1 -i maeve-csms-everest-org.patch

echo "Patching the CSMS to enable local mo root"
patch -p1 -i ../everest-demo/maeve/maeve-csms-local-mo-root.patch
patch -p1 -i maeve-csms-local-mo-root.patch

else
echo "Patching the CSMS to disable WSS"
patch -p1 -i ../everest-demo/maeve/maeve-csms-no-wss.patch
patch -p1 -i maeve-csms-no-wss.patch
fi

8 changes: 0 additions & 8 deletions maeve/build-and-run.sh

This file was deleted.

Empty file.
31 changes: 31 additions & 0 deletions maeve/config/certificates/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Temporary file for process substitution
temp_file := /tmp/temp.ext

all: csms.pem cpo_sub_ca1.pem cpo_sub_ca2.pem root-V2G-cert.pem trust.pem

csms.key:
openssl ecparam -name prime256v1 -genkey -noout -out csms.key

csms.csr: csms.key
openssl req -new -nodes -key csms.key \
-subj "/CN=CSMS/O=Thoughtworks" \
-addext "subjectAltName = DNS:localhost, DNS:gateway, DNS:lb" \
-out csms.csr

csms.pem: csms.csr
echo "basicConstraints = critical, CA:false" > $(temp_file)
echo "keyUsage = critical, digitalSignature, keyEncipherment" >> $(temp_file)
echo "subjectAltName = DNS:localhost, DNS:gateway, DNS:lb" >> $(temp_file)
openssl x509 -req -in csms.csr \
-out csms.pem \
-signkey csms.key \
-days 365 \
-extfile $(temp_file)
rm -f $(temp_file)

cpo_sub_ca1.pem cpo_sub_ca2.pem root-V2G-cert.pem trust.pem:
../../scripts/get-ca-cert.sh

.PHONY: clean
clean:
rm -f *.pem csms.key csms.csr
5 changes: 5 additions & 0 deletions maeve/config/certificates/cpo_sub_ca1.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIN14U+Uag5mVXNx2V625fH5I1F8xRFM8jocunYGEmxp7oAoGCCqGSM49
AwEHoUQDQgAE1UykoMyJkCppRZKnKE+3jtWVK3HVaLHjyheLPJz64dAUeFb0dPnZ
sxqA7ipr6oZStzbQXcieXi+GdMSd/G4+8g==
-----END EC PRIVATE KEY-----
15 changes: 15 additions & 0 deletions maeve/config/certificates/cpo_sub_ca1.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-----BEGIN CERTIFICATE-----
MIICVzCCAf2gAwIBAgICMDowCgYIKoZIzj0EAwIwSDESMBAGA1UEAwwJVjJHUm9v
dENBMRAwDgYDVQQKDAdFVmVyZXN0MQswCQYDVQQGEwJERTETMBEGCgmSJomT8ixk
ARkWA1YyRzAeFw0yNDAzMTIwMTQzMDlaFw0zNDAzMTAwMTQzMDlaMEgxEjAQBgNV
BAMMCUNQT1N1YkNBMTEQMA4GA1UECgwHRVZlcmVzdDELMAkGA1UEBhMCREUxEzAR
BgoJkiaJk/IsZAEZFgNWMkcwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAS6im4H
nE9OlHDLNNUZl3NJZE4ald0+VfNiCySQWdCP/Fwl1zWSZKMidAml0BL0/lihyYO+
cvAEM1NIYrxjQzW3o4HWMIHTMBIGA1UdEwEB/wQIMAYBAf8CAQEwDgYDVR0PAQH/
BAQDAgEGMB0GA1UdDgQWBBRvu7duCmt/mCRfjjMrxNC3MxpQvTBtBggrBgEFBQcB
AQRhMF8wJAYIKwYBBQUHMAGGGGh0dHBzOi8vd3d3LmV4YW1wbGUuY29tLzA3Bggr
BgEFBQcwAoYraHR0cHM6Ly93d3cuZXhhbXBsZS5jb20vSW50ZXJtZWRpYXRlLUNB
LmNlcjAfBgNVHSMEGDAWgBSmkv3Hh77+YEsp57+VsBjmwzITVjAKBggqhkjOPQQD
AgNIADBFAiEA/nLc3K3Fsn4bK+9OFoTfkYJoVEl4NsyTVq4Ga71Dms4CIDyk2XU9
/I7/KL6+oveVLYlvuOfBi489Rr4alOBR+L3L
-----END CERTIFICATE-----
13 changes: 13 additions & 0 deletions maeve/config/certificates/csms_leaf.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-----BEGIN CERTIFICATE-----
MIIB6zCCAZGgAwIBAgICMDwwCgYIKoZIzj0EAwIwSDESMBAGA1UEAwwJQ1BPU3Vi
Q0EyMRAwDgYDVQQKDAdFVmVyZXN0MQswCQYDVQQGEwJERTETMBEGCgmSJomT8ixk
ARkWA1YyRzAeFw0yNDAzMTIwMTQzMDlaFw0zNDAzMTAwMTQzMDlaMFMxHTAbBgNV
BAMMFGhvc3QuZG9ja2VyLmludGVybmFsMRAwDgYDVQQKDAdFVmVyZXN0MQswCQYD
VQQGEwJERTETMBEGCgmSJomT8ixkARkWA0NQTzBZMBMGByqGSM49AgEGCCqGSM49
AwEHA0IABH4hdFZ4+OPvMSLfwcLxvGRflEk7I5zUfQhs9J55DXBo+iv74EtJI/Qg
kf1Cl2S1BK5lGb2o2XekeIYIHOyFIxOjYDBeMAwGA1UdEwEB/wQCMAAwDgYDVR0P
AQH/BAQDAgOIMB0GA1UdDgQWBBSRJ5Mlf4CqG2mbvHj3PE++7WnnpjAfBgNVHSME
GDAWgBSdZoihKocUHKu7g0HVL7/kHarXuzAKBggqhkjOPQQDAgNIADBFAiEAqxo/
vWSzHj/415lXYoD1lrh2HgaTS8BxOR5hY44g9KcCIDFHQ2v39OV6fSETzF5VFU2/
MblV+2toVvnyuDX5rM8v
-----END CERTIFICATE-----
47 changes: 47 additions & 0 deletions maeve/config/manager/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[api]
addr = ":9410"

[transport]
type = "mqtt"
mqtt.urls = ["mqtt://mqtt:1883"]

[ocpi]
addr = ":9411"
external_url = "http://manager:9411"
country_code = "GB"
party_id = "TWK"

[storage]
type = "firestore"
firestore.project_id = "*detect-project-id*"

[contract_cert_validator]
type = "ocsp"

[contract_cert_validator.ocsp.root_certs]
type = "opcp"
opcp.url = "https://open.plugncharge-test.hubject.com"
opcp.ttl = "24h"
opcp.auth.type = "hubject_test_token"
opcp.auth.hubject_test_token.url = "https://hubject.stoplight.io/api/v1/projects/cHJqOjk0NTg5/nodes/6bb8b3bc79c2e-authorization-token"
opcp.auth.hubject_test_token.ttl = "6h"

[contract_cert_provider]
type = "opcp"
opcp.url = "https://open.plugncharge-test.hubject.com"
opcp.auth.type = "hubject_test_token"
opcp.auth.hubject_test_token.url = "https://hubject.stoplight.io/api/v1/projects/cHJqOjk0NTg5/nodes/6bb8b3bc79c2e-authorization-token"
opcp.auth.hubject_test_token.ttl = "6h"

[charge_station_cert_provider]
type = "delegating"
delegating.v2g.type = "opcp"
delegating.v2g.opcp.url = "https://open.plugncharge-test.hubject.com"
delegating.v2g.opcp.auth.type = "hubject_test_token"
delegating.v2g.opcp.auth.hubject_test_token.url = "https://hubject.stoplight.io/api/v1/projects/cHJqOjk0NTg5/nodes/6bb8b3bc79c2e-authorization-token"
delegating.v2g.opcp.auth.hubject_test_token.ttl = "6h"
delegating.cso.type = "local"
delegating.cso.local.cert.type = "file"
delegating.cso.local.cert.file = "/certificates/csms.pem"
delegating.cso.local.key.type = "file"
delegating.cso.local.key.file = "/certificates/csms.key"
19 changes: 19 additions & 0 deletions maeve/config/mosquitto/mosquitto.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Listeners
listener 1883
protocol mqtt

listener 9000
protocol websockets

# Logging
log_dest stdout
log_type error
log_type warning
log_type notice
log_type information
log_timestamp true
log_timestamp_format %Y/%m/%d %H:%M:%S
connection_messages false

# Security
allow_anonymous true
Loading

0 comments on commit dbc2f2d

Please sign in to comment.