Skip to content

Commit e603a9d

Browse files
authored
Add a script to init the line catalog (#427)
Signed-off-by: David BRAQUART <[email protected]>
1 parent 7a3b568 commit e603a9d

File tree

6 files changed

+32
-7
lines changed

6 files changed

+32
-7
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ $ chmod 777 cases postgres elasticsearch init
2121
|---------------------------------------------------------------------------------------------------------------------------------|
2222

2323

24-
<a name="data_init"></a>All databases are created automatically at start as well as the necessary initial data loading (geographical, cgmes boundaries, tsos, ...).
24+
<a name="data_init"></a>When the postgres container is created, all databases are created automatically as well as the necessary initial data loading (geographical, cgmes boundaries, tsos, lines catalog...).
2525

26-
To do this, you must copy the following files in the init directory :
26+
To do this, you must copy the following files in the init directory (_$GRIDSUITE_DATABASES/init_), **before** creating the postgres container:
2727
- [geo_data_substations.json](https://raw.githubusercontent.com/gridsuite/geo-data/main/src/test/resources/geo_data_substations.json)
2828
- [geo_data_lines.json](https://raw.githubusercontent.com/gridsuite/geo-data/main/src/test/resources/geo_data_lines.json)
2929
- [business_processes.json](https://raw.githubusercontent.com/gridsuite/cgmes-boundary-server/main/src/test/resources/business_processes.json)
3030
- [tsos.json](https://raw.githubusercontent.com/gridsuite/cgmes-boundary-server/main/src/test/resources/tsos.json)
31+
- [lines-catalog.json](https://raw.githubusercontent.com/gridsuite/network-modification-server/main/src/test/resources/lines-catalog.json)
3132

3233
### Clone deployment repository
3334

@@ -64,11 +65,11 @@ $ cd docker-compose/dynamic-mapping
6465
$ docker compose up
6566
```
6667

67-
__Notes__ : When using docker-compose for deployment, your machine is accessible from the containers thought the ip address 172.17.0.1
68+
__Note__ : When using docker-compose for deployment, your machine is accessible from the containers thought the ip address 172.17.0.1
6869

69-
__Notes__ : The containers are accessible from your machine thought the ip address `127.0.0.1` (localhost) or `172.17.0.1` and the corresponding port
70+
__Note__ : The containers are accessible from your machine thought the ip address `127.0.0.1` (localhost) or `172.17.0.1` and the corresponding port
7071

71-
__Notes__ :
72+
__Note__ :
7273
These folders (other than `explicit-profiles`) act now like an alias to `docker compose --project-name grid<name> --profile <folder_name> ...`,
7374
with the difference that they have implicitly a profile active and will be considered like another project stack,
7475
so compose commands will not affect others folders state.
@@ -481,9 +482,10 @@ Alternatively, you can do this :
481482

482483
With a terminal, go to the docker directory where you ran the `docker compose up -d` command.
483484

484-
Make sure the `postgres`, `odre-server` and `geo-data-server` services are up with the `docker compose ps` command.
485+
Make sure the `postgres`, `odre-server`, `geo-data-server` and `network-modification-server` services are up with the `docker compose ps` command.
485486
```bash
486487
$ docker compose exec postgres /init-geo-data.sh
488+
$ docker compose exec postgres /init-lines-catalog.sh
487489
$ docker compose exec postgres /init-merging-data.sh
488490
```
489491

docker-compose/study/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
PROJECT_DIR_NAME=study
2+
PROJECT_STUDY_DIR_NAME=study
23
COMPOSE_PATH_SEPARATOR=:
34
COMPOSE_PROJECT_NAME=gridstudy
45
COMPOSE_FILE=docker-compose.override.yml:../docker-compose.base.yml:../merging/docker-compose.override.yml:../dynamic-mapping/docker-compose.override.yml:../technical/docker-compose.technical.yml

docker-compose/suite/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
PROJECT_DIR_NAME=suite
2+
PROJECT_SUITE_DIR_NAME=suite
23
COMPOSE_PATH_SEPARATOR=:
34
COMPOSE_PROJECT_NAME=gridsuite
45
COMPOSE_FILE=docker-compose.marker.yml:../docker-compose.base.yml:../study/docker-compose.override.yml:../merging/docker-compose.override.yml:../dynamic-mapping/docker-compose.override.yml:../technical/docker-compose.technical.yml

docker-compose/technical/docker-compose.technical.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ services:
4545
- $PWD/../technical/init-databases.sh:/init-databases.sh:Z
4646
- $PWD/../technical/init-geo-data.sh:/init-geo-data.sh:Z
4747
- $PWD/../technical/init-merging-data.sh:/init-merging-data.sh:Z
48+
- $PWD/../technical/init-lines-catalog.sh:/init-lines-catalog.sh:Z
4849
restart: unless-stopped
4950

5051
postgres-exporter:

docker-compose/technical/init-databases.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
set -e
44

55
/create-postgres-databases.sh &
6-
76
/init-geo-data.sh &
87
/init-merging-data.sh &
8+
/init-lines-catalog.sh &
99

1010
exec docker-entrypoint.sh "$@"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
function init_lines_catalog()
6+
{
7+
LINES_CATALOG=/init-data/lines-catalog.json
8+
if [ -f $LINES_CATALOG ]; then
9+
curl -X 'POST' -f -s -o /dev/null 'http://network-modification-server/v1/network-modifications/catalog/line_types' -H "Content-Type: application/json" -d "@${LINES_CATALOG}"
10+
fi
11+
}
12+
13+
if [ "$PROJECT_DIR_NAME" == "$PROJECT_STUDY_DIR_NAME" ] || [ "$PROJECT_DIR_NAME" == "$PROJECT_SUITE_DIR_NAME" ]
14+
then
15+
until init_lines_catalog
16+
do
17+
echo "curl: network-modification-server is unavailable to initialize data - will retry later"
18+
sleep 5
19+
done
20+
fi

0 commit comments

Comments
 (0)