Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a2346b8
Improving setup.py
malex984 Aug 30, 2018
f781452
TODO!!!
malex984 Oct 1, 2018
4bf03e8
TODO: FIXME: separate!
malex984 Oct 1, 2018
5a7df25
TODO: starting to add "native" driver
malex984 Apr 11, 2018
8e18f82
TODO: more native + nohup
malex984 Apr 11, 2018
f881440
Add exit/return code from run_action + some minor fixes/improvements
malex984 Oct 1, 2018
961998a
Add reboot, app_restart, run_shell_cmd top level commands to hilbert-…
malex984 Oct 1, 2018
7ee989c
Add repeated WOL execution with randomized delays to avoid stalling /…
malex984 Sep 28, 2018
d59cebb
Update README
malex984 Mar 6, 2019
c745182
Add a wrapper for `sleep`
malex984 Apr 24, 2019
47d1d97
Enable delayed (by a few seconds) shutdown + avoid blocking systemd's…
malex984 Apr 24, 2019
ab87356
Ensure restart of PulseAudio (until it runs)
malex984 Apr 24, 2019
8329779
Projector controlling tool to start/stop corresponding projector on s…
malex984 Apr 24, 2019
1ecab37
Improved systemd unit to kill NODM on poweroff (to avoid X11 restarting)
malex984 Apr 24, 2019
b41c1d4
Ensure that station is online before starting NODM (and Hilbert
malex984 Apr 24, 2019
15ffbd5
Ensure immediate station shutdown (via ssh)
malex984 Apr 24, 2019
a9b62e7
Allow multiple-level extention for stations
malex984 Apr 24, 2019
ef71258
Rule to build hilbert server-side tool
malex984 Apr 24, 2019
8859eca
Bump package version for `hilbert-cli`
malex984 Apr 24, 2019
30a2fa6
Update bash config generation
malex984 Apr 29, 2019
b092aad
More detailed version reporting about the server-side hilbert tool
malex984 Apr 29, 2019
e7cef23
Remove default list of projectors + minor cleanup
malex984 May 2, 2019
41ef3a6
Projector.py: Improve socket_communicator to handle more network fail…
malex984 May 2, 2019
b9a28c2
Projector.py: fix/improve server_connection
malex984 May 2, 2019
192ba8d
Projector.py: do not force lowercase on target-id-spec except for `all`
malex984 May 2, 2019
7b6fff0
Projector.py: ensure that `send_requests` correctly works in case of …
malex984 May 2, 2019
9fd9a76
projector.py: ask crestron for the list of projectors (PRJ_LIST=?) an…
malex984 May 2, 2019
095412f
Add Hilbert pause command into client-side tool
malex984 May 31, 2019
314e52d
Fix: correct handling of remote shutdown
malex984 May 31, 2019
734166e
Cosmetic corrections of hilbert-station
malex984 May 31, 2019
b1e2d1a
Let hilbert pause station's services and application before rebooting it
malex984 May 31, 2019
8d6f318
Version bumping in hilbert-cli.spec
malex984 Jun 5, 2019
9e511d4
Fixed a bug due to missing current-configuration link ($HILBERT_BASE_…
malex984 Jun 26, 2019
7a32cc1
Add cmd_docker_cleanup into hilbert-station for cleaning docker engin…
malex984 Jun 27, 2019
47079c5
Better use "$*" instead of "$@" in some cases in bash scripts (hilber…
malex984 Jun 27, 2019
c426d42
The following is only supported by newer docker CLI:
malex984 Jun 27, 2019
6f4ed8f
Updated the spec file for hilbert-cli RPM
malex984 Jul 3, 2019
95b3091
Added `hilbert cleanup` server-side command for client-side `hilbert-…
malex984 Jul 3, 2019
3e17660
Add optional boolean argument `--force` to station cleanup action
malex984 Jul 3, 2019
8f14ed5
Added `hilbert-station cleanup` alias for `hilbert-station
malex984 Jul 8, 2019
c1eac30
Ensure that `hilbert` server-side tool does not create incorrect config
malex984 Jul 8, 2019
e6882e7
Increase version of hilbert-cli RPM
malex984 Jul 8, 2019
9019844
Add optional strings (url, name, description) for docker-compose
malex984 Jul 29, 2019
80a07f2
Add HOWTO
malex984 Jul 31, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ clean: # Clean Project
rm -rf *~ docs/doxy docs/epydoc docs/pylint_*.html docs/pep8.report.txt

dist/hilbert: hilbert.spec
pyinstaller hilbert.spec # may need to be run with a proper Python interpreter, if several are available
${HOME}/.local/bin/pyinstaller3 hilbert.spec # may need to be run with a proper Python interpreter, if several are available

dist: setup.py
python3 setup.py sdist
Expand Down
57 changes: 28 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,25 @@ Travis CI Build Status: [![devel](https://travis-ci.org/hilbert/hilbert-cli.svg?

# General notes about shell scripts:

* Exit codes may be as follows (see `status.sh`, others will be updated):
* Exit codes may be as follows:
* 0: success
* 1: detected error which is not our fault (e.g. network / HW etc): user can try again
* 2: error due to wrong usage of scripts / in config files or some assumption was violated.
* other positive values: something unexpected has happened.

* One may need to capture both `STDOUT` and `STDERR`. Error messages (in `STDERR`) that are meant to be presented to users (admins) must be as informative as possible.

# UI Back-end: high-level action scripts

* `list_stations.sh`: query current YAML configuration (`hilbert list_stations --format dashboard`)
* `start_station.sh`: start stopped station (`hilbert poweron $station_id`)
1. initiates station power-on (e.g. via WOL)
* `appchange_station.sh`: switch GUI applicaiton running on the station `hilbert app_change $station_id $app_id`
1. switch GUI app. on the station
* `stop_station.sh`: stop station (`hilbert poweroff $station_id`):
1. gracefully finish (stop / kill / remove) all running framework' services
2. initiate system shutdown (with power-off) of the station (alternative: `poweroff.sh $station_id`)

NOTE: rebooting the station can be done with: `shutdown.sh STATION -r now` or `reboot.sh STATION`

TODOs:
* `sync.sh` (to synchronize local cache `STATIONS/` with station configs & scripts from CMS).
Sync. is to be performed once before front-end starts & upon request from CMS (external trigger!):
* `start_station.sh` will not wait for remote machine to power-on completely - there should be a wait on OMD afterwards
* `stop_station.sh` and `appchange_station.sh` should trigger update of OMD checks

# Server-side low-level management CLI tool:

```
usage: hilbert [-h] [-p] [-V] [-v | -q] [-H] subcommand
usage: hilbert [-h] [-p] [-t] [-d] [-V] [-v | -q] [-H] subcommand

Hilbert - server tool: loads configuration and does something using it

positional arguments:
subcommand :
app_change change station's top application
app_restart restart current/default application on a station
cfg_deploy deploy station's local configuration to corresponding host
cfg_query query some part of configuration. possibly dump it to a file
cfg_verify verify the correctness of Hilbert Configuration .YAML file
Expand All @@ -59,50 +41,67 @@ positional arguments:
list_stations list station IDs
poweroff finalize Hilbert on a station and shut it down
poweron wake-up/power-on/start station
reboot reboot station
run_shell_cmd run specified shell command on given station...

optional arguments:
-h, --help show this help message and exit
-p, --pedantic turn on pedantic mode
-t, --trace turn on remote verbose-trace mode
-d, --dryrun increase dry-run mode
-V, --version show hilbert's version and exit
-v, --verbose increase verbosity
-q, --quiet decrease verbosity
-H, --helpall show detailed help and exit

```

# Client-side low-level driver (accessible either locally or via SSH):


```
usage: hilbert-station [-h] [-p] [-V] [-v | -q] subcommand
usage: hilbert-station [-v|-q|-s] [-d|-D] [-t|-T] [-L] [-i|-h|-V|subcommand] [sub-arguments/options]

Hilbert - client part for Linux systems

positional arguments:
subcommand:
subcommands:
init [<cfg>] init station based on given or installed configuration
list_applications list of (supported) applications
list_services list of background services
app_change <app_id> change the currently running top application to specified
start start Hilbert on the system
start [app_id] start Hilbert on the system
stop stop Hilbert on the system
shutdown shut down the system

optional arguments:
-h show this help message and exit
-V show version info and exit
-h show this help message [+internal commands/call tree, depending on verbosity] and exit
-V show tool version [+internal info in verbose mode] and exit
-i show internal info and exit
-v increase verbosity
-q decrease verbosity
-s silent: minimal verbosity
-t turn on BASH tracing and verbosity
-T turn off BASH tracing and verbosity
-d turn on dry-run mode
-D turn off dry-run mode
-L disable locking (e.g. for recursive sub-calls)

respected environment variables:
HILBERT_CONFIG_BASEDIR location of the base configuration directory of hilbert-station. Default: '~/.config/hilbert-station'
HILBERT_CONFIG_BASEDIR base configuration directory. Current: [~/.config/hilbert-station]
HILBERT_CONFIG_DIR configuration directory. Current: [~/.config/hilbert-station/configs]
HILBERT_CONFIG_FILE station config file. Current: [station.cfg]

currently detected hilbert variables/values:
HILBERT_SERVER_CONFIG_PATH: ...
HILBERT_CONFIG_BACKUP: ~/.config/hilbert-station/config_backup
HILBERT_SHUTDOWN_DELAY: 1s
HILBERT_LOCKFILE_DIR: /var/run/hilbert
HILBERT_STATION: .../bin/hilbert-station
```

NOTE: all commands (except `init <cfg>` / `shutdown` / `-h` / `-V`) require station's configuration to be present


## License
This project is licensed under the [Apache v2 license](LICENSE). See also [Notice](NOTICE).


180 changes: 180 additions & 0 deletions docs/HOWTO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# How-To guides for Hilbert system

Note: on a server "${HILBERT_SERVER_CONFIG_PATH}" should be equal to "/shared/interactives/0000_general/Hilbert/CFG/"

## Add a new PC into a hilbert setup

1. fix a DNS name (KIOSK_ADDRESS) for a new station (e.g. `kiosk023XXX.ads.eso.org`)
2. decide on proper <STATION_ID> for it (according to the following schema: `client_[0-9][0-9][0-9][0-9](_[0-9])?`)
3. depending on its HW decide on corresponding profile (i.e. set of services) to run on PC by default
4. add it into OMD (see below)
5. add it into `/shared/interactives/0000_general/Hilbert/CFG/Hilbert.yml` configuration
* by analogy with existing stations but with its own unique networking and MAC addresses!
6. restart the Dashboard

## Add a station into OMD

Note: OMD Login credentials are present in other document with secrets

Let us add a station with ID: `<STATION_ID>` and network address: `<KIOSK_ADDRESS>`

NOTE: make sure that station is running Hilbert already (in order to discover all available CheckMK services on it)

Create new host entry via: http://es-ex.hq.eso.org/default/check_mk/wato.py?mode=newhost&folder=

1. `Hostname` set to be `<STATION_ID>`
2. check `IP address` and set input field to be `<KIOSK_ADDRESS>`
3. press bottom-left button: "Save and go to serrvices"
4. on "Services of host `<STATION_ID>` (might be cached data)" there should be around 20 services (most of them should be green)
5. press button "Automatic Refresh (Tabula Rasa)"

After you are done adding all stations go to top button "... Changes": http://es-ex.hq.eso.org/default/check_mk/wato.py?mode=changelog&folder=
and press button "Activate Changes!"

Result should be:

```
Progress Status
OK Configuration successfully activated.
```

## Check Hilbert configuration and docker-compose files

Run the following on your current server:
```
$ cd /shared/interactives/0000_general/Hilbert/CFG
$ ./check_cfg.sh
```

## Deployment of Hilbert configuration to specified station (or refresh/update Hilbert there)

Run the following on your current server:
```
$ cd /shared/interactives/0000_general/Hilbert/CFG
$ ./hilbert cfg_deploy <STATION_ID>
```

Note: on remote station Hilbert configuration will by installed under `~/.config/hilbert-station/` by default.
Only Hilbert client-side CLI tool `hilbert-station` is supposed to work with it.


## Cleanup remote station

Run the following on your current server:

```
$ cd /shared/interactives/0000_general/Hilbert/CFG
$ ./hilbert cleanup <STATION_ID>
```

Alternatively after logging-in to corresponding host (via `hilbert-ssh <STATION_ID>` or `ssh <KIOSK_ADDRESS>`) via ssh run the following:
```
$ hilbert-station cleanup # or
$ hilbert-station cleanup --force # if Hilbert is currently running
```



## Hilbert client-side CLI tool: `hilbert-station`

```
usage: hilbert-station [-v|-q|-s] [-d|-D] [-t|-T] [-L] [-i|-h|-V|subcommand] [sub-arguments/options]

Hilbert - client part for Linux systems

positional arguments:
subcommands:
init [<cfg>] init station based on given or installed configuration
list_applications list of (supported) applications
list_services list of background services
app_change <app_id> change the currently running top application to specified
app_restart restart the currently running top application
start [<app_id>] start Hilbert on the system
pause pause Hilbert on the system
stop stop Hilbert on the system
shutdown [now] shut down the system
reboot [now] reboot the system
cleanup [--force] local system cleanup (identical to docker_cleanup on Linux host)
docker_cleanup [--force] total cleanup of local docker engine (images, data volumes)

optional arguments:
-h show this help message [+internal commands/call tree, depending on verbosity] and exit
-V show tool version [+internal info in verbose mode] and exit
-i show internal info and exit
-v increase verbosity
-q decrease verbosity
-s silent: minimal verbosity
-t turn on BASH tracing and verbosity
-T turn off BASH tracing and verbosity
-d turn on dry-run mode
-D turn off dry-run mode
-L disable locking (e.g. for recursive sub-calls)
```

Note: `hilbert-station` is a bash script installed on station via `hilbert-cli-*.rpm`.
Its source is available at https://github.com/hilbert/hilbert-cli/ (in `tools/hilbert-station`)



## Hilbert server-side CLI tool

```
$ hilbert
usage: hilbert [-h] [-p] [-t] [-d] [-V] [-v | -q] [-H] subcommand

Hilbert - server tool: loads configuration and does something using it

positional arguments:
subcommand :
app_change change station's top application
app_restart restart current/default application on a station
cfg_deploy deploy station's local configuration to corresponding host
cfg_query query some part of configuration. possibly dump it to a file
cfg_verify verify the correctness of Hilbert Configuration .YAML file
cleanup perform system cleanup on remote station
list_applications list application IDs
list_groups list (named) group IDs
list_profiles list profile IDs
list_services list service IDs
list_stations list station IDs
poweroff finalize Hilbert on a station and shut it down
poweron wake-up/power-on/start station
reboot reboot station
run_shell_cmd run specified shell command on given station...

optional arguments:
-h, --help show this help message and exit
-p, --pedantic turn on pedantic mode
-t, --trace turn on remote verbose-trace mode
-d, --dryrun increase dry-run mode
-V, --version show hilbert's version and exit
-v, --verbose increase verbosity
-q, --quiet decrease verbosity
-H, --helpall show detailed help and exit
```

Run `hilbert -H` for detailed information on all commands

Note: `hilbert` is a CLI packaged Python script. Its sources are available at https://github.com/hilbert/hilbert-cli


## Hilbert Data/Configuration Restoration for a server

See also `/shared/server.backup_restore/README.md` for more details

Note: the procedure will take quite a long time therefore it is better to run it
within some terminal multiplexer (e.g. `screen` or `tmux`) so that it will not be interrupted
if your connection to server is cut.

Suggested procedure:

1. login as `kiosk` user to new (empty) server
2. check that NFS mounted disk `/shared` is present
3. run `tmux` (or `screen`): should start another shell line, where you run the following command:
4. run `/shared/server.backup_restore/bin/restore.sh`

NOTE: Please do not use `Ctrl+C` to exit.
Use `Crtl+b d` or `Ctrl+a d` to detach from multiplexer session.
Later on you can attach back to previous session with `tmux at` after logging to the server.

NOTE: do not use `root` for restoration!
2 changes: 1 addition & 1 deletion hilbert_config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import absolute_import
from __future__ import unicode_literals

__version__ = '0.3.0' # TODO: add git commit id?
__version__ = '0.4.0' # TODO: add git commit id?

# from hilbert_cli_config import *
Loading