wmo-im / wis2box

WIS2 in a box is a reference implementation of a WMO WIS2 Node
https://docs.wis2box.wis.wmo.int
Apache License 2.0
40 stars 16 forks source link

Add wis2box-create-config.py to generate configuration files #473

Closed maaikelimper closed 1 year ago

maaikelimper commented 1 year ago

In order to simplify the wis2box-configuration, we could have a script that is run from the command-line and asks the users for a series of questions and then generates the configuration-files.

So in addition to 'wis2box-ctl.py' we would have 'wis2box-create-config.py'

'wis2box-ctl.py' could run a test to check if the configuration-files are missing and suggest the user to run 'wis2box-create-config.py' first.

maaikelimper commented 1 year ago
maaikelimper commented 1 year ago

@tomkralidis Can we provide default keywords for synop and temp discovery metadata ?

maaikelimper commented 1 year ago

I've created PR #476 for this.

Here is how it works:

The user executes the new script 'wis2box-create-config.py' and answers a series of question on the command-line:

PS C:\Users\maaik\Documents\GitHub\wis2box> python wis2box-create-config.py
The file dev.env already exists in the current directory.
Do you want to recreate dev.env? (y/n/exit)
y
Please enter the directory on the host where wis2box-configuration-files are to be stored:
C:\wis2box-data
Configuration-files will be stored in the following directory:
    C:\wis2box-data
Is this correct? (y/n/exit)
y
The directory C:\wis2box-data has been created.
Please enter the URL of the wis2box:
 When running the wis2box locally, the default is http://localhost
 To enable remote access, please enter the public IP address or domain name of the server hosting the wis2box.
http://127.0.0.1
The URL of the wis2box will be set to:
  http://127.0.0.1
Is this correct? (y/n/exit)
y
Do you want to use a randomly generated password for WIS2BOX_STORAGE_PASSWORD (y/n/exit)
y
WIS2BOX_STORAGE_PASSWORD=46G0urkH
Do you want to use a randomly generated password for WIS2BOX_BROKER_PASSWORD (y/n/exit)
y
WIS2BOX_BROKER_PASSWORD=Sde9QuCa
********************************************************************************
The file dev.env has been created in the current directory.
********************************************************************************
Please enter your 3-letter ISO country-code:
ITA
Please enter the centre-id for your wis2box:
maaike_test
The country-code will be set to:
  ita
The centre-id will be set to:
  maaike_test
Is this correct? (y/n/exit)
y
********************************************************************************
Creating initial configuration for surface and upper-air data.
********************************************************************************
Please enter the email address of the wis2box administrator:
me@gmail.com
The email address of the wis2box administrator will be set to:
    me@gmail.com
Is this correct? (y/n/exit)
y
Please enter the name of your organization:
Maaike TEST
Your organization name will be set to:
    Maaike TEST
Is this correct? (y/n/exit)
y
Getting bounding box for 'ita'.
bounding box: 6.6272658,35.2889616,18.7844746,47.0921462.
Do you want to use this bounding box? (y/n/exit)
y
Created new metadata-file:
    C:\wis2box-data/metadata/discovery/metadata-synop.yml
Created new metadata-file:
    C:\wis2box-data/metadata/discovery/metadata-temp.yml
********************************************************************************
Initial metadata files have been created in the directory C:\wis2box-data.
Please review the files and edit where necessary.
********************************************************************************
********************************************************************************
Initial data_mappings.yml and csv2bufr_mappings.json have been created
Please review the files and update them as needed.
********************************************************************************
********************************************************************************
Created the file C:\wis2box-data/metadata/station/station_list.csv.
Please add your stations to this file.
********************************************************************************
The configuration is complete.

Then start the wis2box: PS C:\Users\maaik\Documents\GitHub\wis2box> python wis2box-ctl.py start

Login to the wis2box: PS C:\Users\maaik\Documents\GitHub\wis2box> python wis2box-ctl.py login

Run the publish and add-collection commands:

root@05b5a305fd63:/home/wis2box# wis2box data add-collection /data/wis2box/metadata/discovery/metadata-synop.yml
Done
root@05b5a305fd63:/home/wis2box# wis2box data add-collection /data/wis2box/metadata/discovery/metadata-temp.yml
Done
root@05b5a305fd63:/home/wis2box# wis2box metadata discovery publish /data/wis2box/metadata/discovery/metadata-synop.yml
Publishing discovery metadata from /data/wis2box/metadata/discovery/metadata-synop.yml
Done
root@05b5a305fd63:/home/wis2box# wis2box metadata discovery publish /data/wis2box/metadata/discovery/metadata-temp.yml 
Publishing discovery metadata from /data/wis2box/metadata/discovery/metadata-temp.yml
Done

And visit the URL specified by the user to see:

image

tomkralidis commented 1 year ago

@tomkralidis to review by end of 30 August.