dtaas-services 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. dtaas_services-0.3.0/PKG-INFO +347 -0
  2. dtaas_services-0.3.0/README.md +325 -0
  3. dtaas_services-0.3.0/dtaas_services/__init__.py +0 -0
  4. dtaas_services-0.3.0/dtaas_services/cmd.py +37 -0
  5. dtaas_services-0.3.0/dtaas_services/commands/__init__.py +1 -0
  6. dtaas_services-0.3.0/dtaas_services/commands/service_ops.py +172 -0
  7. dtaas_services-0.3.0/dtaas_services/commands/setup_ops.py +225 -0
  8. dtaas_services-0.3.0/dtaas_services/commands/user_ops.py +207 -0
  9. dtaas_services-0.3.0/dtaas_services/commands/utility.py +189 -0
  10. dtaas_services-0.3.0/dtaas_services/pkg/__init__.py +0 -0
  11. dtaas_services-0.3.0/dtaas_services/pkg/cert.py +308 -0
  12. dtaas_services-0.3.0/dtaas_services/pkg/config.py +78 -0
  13. dtaas_services-0.3.0/dtaas_services/pkg/formatter.py +166 -0
  14. dtaas_services-0.3.0/dtaas_services/pkg/lib/__init__.py +15 -0
  15. dtaas_services-0.3.0/dtaas_services/pkg/lib/cleanup.py +219 -0
  16. dtaas_services-0.3.0/dtaas_services/pkg/lib/docker_executor.py +194 -0
  17. dtaas_services-0.3.0/dtaas_services/pkg/lib/initialization.py +75 -0
  18. dtaas_services-0.3.0/dtaas_services/pkg/lib/manager.py +229 -0
  19. dtaas_services-0.3.0/dtaas_services/pkg/lib/status.py +242 -0
  20. dtaas_services-0.3.0/dtaas_services/pkg/lib/utils.py +235 -0
  21. dtaas_services-0.3.0/dtaas_services/pkg/password_store.py +87 -0
  22. dtaas_services-0.3.0/dtaas_services/pkg/services/gitlab/__init__.py +14 -0
  23. dtaas_services-0.3.0/dtaas_services/pkg/services/gitlab/_api.py +86 -0
  24. dtaas_services-0.3.0/dtaas_services/pkg/services/gitlab/app_token.py +165 -0
  25. dtaas_services-0.3.0/dtaas_services/pkg/services/gitlab/health.py +61 -0
  26. dtaas_services-0.3.0/dtaas_services/pkg/services/gitlab/password.py +141 -0
  27. dtaas_services-0.3.0/dtaas_services/pkg/services/gitlab/personal_token.py +214 -0
  28. dtaas_services-0.3.0/dtaas_services/pkg/services/gitlab/setup.py +229 -0
  29. dtaas_services-0.3.0/dtaas_services/pkg/services/gitlab/users.py +240 -0
  30. dtaas_services-0.3.0/dtaas_services/pkg/services/gitlab/validators.py +97 -0
  31. dtaas_services-0.3.0/dtaas_services/pkg/services/influxdb/__init__.py +17 -0
  32. dtaas_services-0.3.0/dtaas_services/pkg/services/influxdb/_utils.py +36 -0
  33. dtaas_services-0.3.0/dtaas_services/pkg/services/influxdb/influxdb.py +100 -0
  34. dtaas_services-0.3.0/dtaas_services/pkg/services/influxdb/user_management.py +198 -0
  35. dtaas_services-0.3.0/dtaas_services/pkg/services/mongodb.py +44 -0
  36. dtaas_services-0.3.0/dtaas_services/pkg/services/postgres/__init__.py +10 -0
  37. dtaas_services-0.3.0/dtaas_services/pkg/services/postgres/postgres.py +200 -0
  38. dtaas_services-0.3.0/dtaas_services/pkg/services/postgres/status.py +88 -0
  39. dtaas_services-0.3.0/dtaas_services/pkg/services/rabbitmq.py +191 -0
  40. dtaas_services-0.3.0/dtaas_services/pkg/services/thingsboard/__init__.py +13 -0
  41. dtaas_services-0.3.0/dtaas_services/pkg/services/thingsboard/activation.py +84 -0
  42. dtaas_services-0.3.0/dtaas_services/pkg/services/thingsboard/checker.py +182 -0
  43. dtaas_services-0.3.0/dtaas_services/pkg/services/thingsboard/customer_user.py +197 -0
  44. dtaas_services-0.3.0/dtaas_services/pkg/services/thingsboard/permissions.py +163 -0
  45. dtaas_services-0.3.0/dtaas_services/pkg/services/thingsboard/setup.py +215 -0
  46. dtaas_services-0.3.0/dtaas_services/pkg/services/thingsboard/setup_credentials.py +81 -0
  47. dtaas_services-0.3.0/dtaas_services/pkg/services/thingsboard/sysadmin.py +154 -0
  48. dtaas_services-0.3.0/dtaas_services/pkg/services/thingsboard/sysadmin_util.py +156 -0
  49. dtaas_services-0.3.0/dtaas_services/pkg/services/thingsboard/tb_cert.py +159 -0
  50. dtaas_services-0.3.0/dtaas_services/pkg/services/thingsboard/tb_utility.py +245 -0
  51. dtaas_services-0.3.0/dtaas_services/pkg/services/thingsboard/tenant_admin.py +264 -0
  52. dtaas_services-0.3.0/dtaas_services/pkg/template.py +116 -0
  53. dtaas_services-0.3.0/dtaas_services/pkg/utils.py +252 -0
  54. dtaas_services-0.3.0/dtaas_services/templates/certs/.gitkeep +0 -0
  55. dtaas_services-0.3.0/dtaas_services/templates/compose.gitlab.yml +30 -0
  56. dtaas_services-0.3.0/dtaas_services/templates/compose.services.yml +122 -0
  57. dtaas_services-0.3.0/dtaas_services/templates/compose.thingsboard.yml +37 -0
  58. dtaas_services-0.3.0/dtaas_services/templates/config/credentials.csv.template +3 -0
  59. dtaas_services-0.3.0/dtaas_services/templates/config/gitlab/.gitkeep +0 -0
  60. dtaas_services-0.3.0/dtaas_services/templates/config/influxdb/.gitkeep +0 -0
  61. dtaas_services-0.3.0/dtaas_services/templates/config/mongod.conf.secure +26 -0
  62. dtaas_services-0.3.0/dtaas_services/templates/config/rabbitmq/rabbitmq.conf +66 -0
  63. dtaas_services-0.3.0/dtaas_services/templates/config/rabbitmq/rabbitmq.enabled_plugins +1 -0
  64. dtaas_services-0.3.0/dtaas_services/templates/config/services.env.template +88 -0
  65. dtaas_services-0.3.0/dtaas_services/templates/data/gitlab/.gitkeep +0 -0
  66. dtaas_services-0.3.0/dtaas_services/templates/data/grafana/.gitkeep +0 -0
  67. dtaas_services-0.3.0/dtaas_services/templates/data/influxdb/.gitkeep +0 -0
  68. dtaas_services-0.3.0/dtaas_services/templates/data/mongodb/.gitkeep +0 -0
  69. dtaas_services-0.3.0/dtaas_services/templates/data/postgres/.gitkeep +0 -0
  70. dtaas_services-0.3.0/dtaas_services/templates/data/rabbitmq/.gitkeep +0 -0
  71. dtaas_services-0.3.0/dtaas_services/templates/data/thingsboard/.gitkeep +0 -0
  72. dtaas_services-0.3.0/dtaas_services/templates/log/gitlab/.gitkeep +0 -0
  73. dtaas_services-0.3.0/dtaas_services/templates/log/thingsboard/.gitkeep +0 -0
  74. dtaas_services-0.3.0/pyproject.toml +44 -0
@@ -0,0 +1,347 @@
1
+ Metadata-Version: 2.3
2
+ Name: dtaas-services
3
+ Version: 0.3.0
4
+ Summary: DTaaS Platform Services Management CLI
5
+ License: INTO-CPS-Association
6
+ Author: Mohamed Abdulkarim
7
+ Requires-Python: >=3.10,<4.0
8
+ Classifier: License :: Other/Proprietary License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Requires-Dist: click (>=8.1.7,<9.0.0)
15
+ Requires-Dist: httpx (>=0.28.1,<0.29.0)
16
+ Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
17
+ Requires-Dist: python-gitlab (>=8.1.0,<9.0.0)
18
+ Requires-Dist: python-on-whales (>=0.75.0,<0.76.0)
19
+ Requires-Dist: rich (>=14.2.0,<15.0.0)
20
+ Description-Content-Type: text/markdown
21
+
22
+ # Platform Services
23
+
24
+ It is recommended to install certain third-party software for use
25
+ by digital twins running inside the DTaaS software.
26
+ _These services can only be installed in secure (TLS) mode._
27
+
28
+ The following services can be installed:
29
+
30
+ * **Influx** time-series database and dashboard service
31
+ * **Grafana** visualization and dashboard service
32
+ * **RabbitMQ** AMQP broker and its' management interface
33
+ The **MQTT plugin** of this broker has been enabled.
34
+ So, it can also be used as **MQTT** broker.
35
+ * **MongoDB** database server
36
+ * **ThingsBoard** IoT device management and data visualization platform
37
+ (with PostgreSQL backend)
38
+ * **GitLab** OAuth2 identity provider and Git repository service
39
+
40
+ ## Directory Structure
41
+
42
+ * **config** is used for storing the service configuration
43
+ * **data** is used by the services for storing data
44
+ * **certs** is used for storing the TLS certificates needed by the services.
45
+ * **cli** contains a CLI package for automated service management
46
+
47
+ ## Installation Methods
48
+
49
+ You can install and manage the services using:
50
+
51
+ **CLI Package :** Automated CLI tool for easy service management.
52
+
53
+ ## DTaaS Services CLI
54
+
55
+ A command-line tool for managing DTaaS platform services including MongoDB,
56
+ InfluxDB, RabbitMQ, Grafana, ThingsBoard, and GitLab.
57
+
58
+ ## Features
59
+
60
+ * **Project Initialization:** Generate project structure with config and data directories
61
+ * **Automated Setup:** One command setup of TLS certificates and permissions
62
+ * **Service Management:** Start, stop, and check status of all services
63
+ * **User Management:** Easy creation of user accounts in InfluxDB,
64
+ RabbitMQ, ThingsBoard, and GitLab
65
+ * **Cross platform:** Works on Linux, macOS, and Windows
66
+ * **Configuration-driven:** Reads settings from `config/services.env`
67
+
68
+ ## Installation
69
+
70
+ ### Prerequisites
71
+
72
+ * Python 3.10 or higher
73
+ * Docker and Docker Compose
74
+ * TLS certificates
75
+
76
+ ### Install from Wheel Package
77
+
78
+ Install the standalone wheel package using pip:
79
+
80
+ ```bash
81
+ pip install dtaas_services-0.3.0-py3-none-any.whl
82
+ ```
83
+
84
+ This installs the `dtaas-services` command.
85
+
86
+ To verify the installation:
87
+
88
+ ```bash
89
+ dtaas-services --help
90
+ ```
91
+
92
+ ## Quick Start
93
+
94
+ 1. Navigate to where you want to set up the services and generate the project
95
+ structure and run:
96
+
97
+ ```bash
98
+ dtaas-services generate-project
99
+ ```
100
+
101
+ This creates:
102
+ * `config/` directory with configuration templates
103
+ * `data/` directory for service data
104
+ * `compose.services.yml` for main services
105
+ * `compose.thingsboard.yml` for ThingsBoard and PostgreSQL
106
+
107
+ 2. Update `config/services.env` with your environment values:
108
+ * `HOSTNAME`: Public hostname of the DTaaS server (used for certificate paths)
109
+ * `GITLAB_PORT`: Port for the local GitLab instance (default: `8090`)
110
+ * `GITLAB_ROOT_NEW_PASSWORD`: Strong password to set for the GitLab root admin
111
+ * `TB_SYSADMIN_NEW_PASSWORD`: New password for the ThingsBoard system admin
112
+ * Port numbers for each service
113
+ * `TB_TENANT_NEW_PASSWORD`: New password for the tenant admin
114
+ * `SERVICES_UID`: User ID for service file ownership
115
+ * `SERVICES_GID`: Group ID for service file ownership
116
+
117
+ 3. Update `config/credentials.csv` with user accounts (format: `username,password,email`)
118
+
119
+ **Options:**
120
+
121
+ * `--path` Directory to generate project structure (default: current directory)
122
+
123
+ **Example:**
124
+
125
+ ```bash
126
+ dtaas-services generate-project --path /path/to/project
127
+ ```
128
+
129
+ ## Usage
130
+
131
+ ### Service Setup
132
+
133
+ After generating the project and configuring your settings:
134
+
135
+ ```bash
136
+ dtaas-services setup
137
+ ```
138
+
139
+ This command will:
140
+
141
+ * Copy TLS certificates to the correct locations
142
+ * Set up MongoDB certificates and permissions
143
+ * Set up InfluxDB certificates and permissions
144
+ * Set up RabbitMQ certificates and permissions
145
+ * Set up PostgreSQL and ThingsBoard certificates and permissions
146
+
147
+ Make sure you run the clean command right after
148
+
149
+ ```bash
150
+ dtaas-services clean
151
+ ```
152
+
153
+ ### Managing Services
154
+
155
+ Now you can manage services by simple commands (Start, Stop, Remove and Restart)
156
+
157
+ Example:
158
+
159
+ ```bash
160
+ dtaas-services start
161
+ ```
162
+
163
+ you can specify a services to manage
164
+
165
+ ```bash
166
+ dtaas-services stop -s influxdb
167
+ ```
168
+
169
+ Remove services and their volumes:
170
+
171
+ ```bash
172
+ dtaas-services remove -v
173
+ # Specify
174
+ dtaas-services remove -v -s <service_name>
175
+
176
+ ```
177
+
178
+ ### User Account Management
179
+
180
+ 1. Edit `config/credentials.csv` with user accounts (format: `username,password,email`)
181
+
182
+ 2. Add users to all supported services:
183
+
184
+ ```bash
185
+ dtaas-services user add
186
+ ```
187
+
188
+ This creates user accounts in InfluxDB, RabbitMQ, ThingsBoard, and GitLab
189
+ (each service is skipped gracefully if it is not running).
190
+ For GitLab, a Personal Access Token is created for each new user and
191
+ saved to `config/gitlab_user_tokens.json`.
192
+
193
+ 3. Add users to a specific service:
194
+
195
+ ```bash
196
+ dtaas-services user add -s rabbitmq
197
+ ```
198
+
199
+ ## ThingsBoard
200
+
201
+ It is recommended to install the third-party software ThingsBoard
202
+ for use by digital twins
203
+ running inside the DTaaS software.
204
+ This service can only be installed in secure (TLS) mode.
205
+
206
+ The steps given above install two services:
207
+
208
+ * **ThingsBoard** is an IoT device management and data visualization platform
209
+ * **PostgreSQL** is a database server for ThingsBoard
210
+
211
+ ### ThingsBoard Directory Structure
212
+
213
+ * **config** is used for storing the service configuration
214
+ * **data** is used by the services for storing data
215
+ * **log** is used by the services for logging
216
+ * **certs** is used for storing the TLS certificates needed by the services
217
+ * **script** contains scripts for creating user accounts and service management
218
+
219
+ ### ThingsBoard Installation
220
+
221
+ > **Warning:** Running `dtaas-services install -s thingsboard` more than once
222
+ > will re-run the ThingsBoard schema migration against an already-populated
223
+ > PostgreSQL database, which can corrupt it. If you need to reinstall from
224
+ > scratch, run `dtaas-services clean -s "postgres,thingsboard"` first to wipe
225
+ > all data before re-running the install command.
226
+ > **Note:** It's recommended to specify the service explicitly with `-s <service>`
227
+ > when installing.
228
+ > Make sure that you have runned the clean command before the installation
229
+
230
+ ```bash
231
+ # (It starts PostgreSQL if it's not running, and it checks its health)
232
+ dtaas-services install -s thingsboard
233
+ ```
234
+
235
+ ```bash
236
+ dtaas-services start -s thingsboard
237
+ ```
238
+
239
+ ```bash
240
+
241
+ # After installation, wait some time before adding users
242
+ # This creates the tenant, tenant admin and users.
243
+ dtaas-services user add -s thingsboard
244
+ ```
245
+
246
+ Reset the ThingsBoard sysadmin and tenant admin passwords using values
247
+ configured in `config/services.env`:
248
+
249
+ ```bash
250
+ dtaas-services user reset-password -s thingsboard
251
+ ```
252
+
253
+ This command:
254
+
255
+ * Changes the sysadmin password from the default (`"sysadmin"`) to `TB_SYSADMIN_NEW_PASSWORD`
256
+ * Changes the tenant admin password from the default (`"tenant"`) to
257
+ `TB_TENANT_ADMIN_PASSWORD`
258
+
259
+ ### GitLab Installation
260
+
261
+ **Prerequisites:**
262
+
263
+ * The GitLab container joins the `dtaas-services` Docker network
264
+ (`platform-services`), which is created automatically when the other
265
+ platform services are running. Start them first with
266
+ `dtaas-services start` before installing GitLab.
267
+ * Set `REACT_APP_AUTH_AUTHORITY` in the client config file
268
+ (`deploy/config/client/env.js` for server deployments, or
269
+ `deploy/config/client/env.local.js` for localhost) to
270
+ `https://<hostname>:<GITLAB_PORT>/gitlab`.
271
+
272
+ > **Note:** The DTaaS client uses `react-oidc-context`, which forces
273
+ > redirects to use HTTPS. GitLab must therefore be served over HTTPS
274
+ > at `https://<hostname>:<GITLAB_PORT>/gitlab`
275
+
276
+ To install and configure the local GitLab instance:
277
+
278
+ ```bash
279
+ dtaas-services install -s gitlab
280
+ ```
281
+
282
+ GitLab takes 5–10 minutes to become healthy after the first start.
283
+ The install command checks GitLab’s readiness and returns immediately:
284
+
285
+ * **If GitLab is healthy**: the command runs post-install setup
286
+ (password reset, PAT creation, OAuth app registration) and
287
+ saves the access token to `config/gitlab_tokens.json`.
288
+ * **If GitLab is still starting**: the command prints a status hint
289
+ and exits. Check progress with `dtaas-services status -s gitlab`
290
+ and re-run `dtaas-services install -s gitlab` once the status
291
+ shows "healthy".
292
+
293
+ > **Note:** After a successful setup, `config/gitlab_tokens.json` is backed
294
+ > up to `config/backup_gitlab_tokens.json` and the `root_password` entry is
295
+ > removed from the live tokens file.
296
+ > If the GitLab installation becomes corrupted before the root password is
297
+ > changed, the initial password can be found in the backup file:
298
+ > `config/backup_gitlab_tokens.json`.
299
+ > If that file is also missing, re-install GitLab to generate a new
300
+ > initial password.
301
+ > **Warning:** `config/password.env.current` is managed automatically by
302
+ > the CLI and tracks the current service passwords. Do **not** edit or delete
303
+ > this file manually — doing so may cause password reset commands to fail.
304
+
305
+ To complete the OAuth2 integration with DTaaS and set up GitLab Runner,
306
+ follow the [integration guide](GITLAB_INTEGRATION.md) and
307
+ [runner setup guide](../runner/GITLAB-RUNNER.md).
308
+
309
+ Reset the GitLab root admin password using the value configured in
310
+ `config/services.env` (`GITLAB_ROOT_NEW_PASSWORD`):
311
+
312
+ ```bash
313
+ dtaas-services user reset-password -s gitlab
314
+ ```
315
+
316
+ The command reads the new password from `GITLAB_ROOT_NEW_PASSWORD`
317
+ and applies it via the GitLab API.
318
+
319
+ ## GitLab Post-Install Flow
320
+
321
+ The `dtaas-services install -s gitlab` command performs the following steps
322
+ automatically:
323
+
324
+ 1. Starts the GitLab Docker container
325
+ 2. Checks if GitLab is healthy (non-blocking — exits immediately if not ready)
326
+ 3. Reads the auto-generated root password from the container
327
+ (`/etc/gitlab/initial_root_password`)
328
+ 4. Creates an initial Personal Access Token and saves it to
329
+ `config/gitlab_tokens.json`
330
+ 5. Creates Server and Client OAuth application tokens.
331
+
332
+ ## Troubleshooting
333
+
334
+ ### Permission Issues (Linux/macOS)
335
+
336
+ If you encounter permission errors when setting up services,
337
+ ensure you run the setup command with appropriate privileges:
338
+
339
+ ```bash
340
+ sudo -E env PATH="$PATH" dtaas-services setup
341
+ ```
342
+
343
+ ### Thingsboard connection error
344
+
345
+ After starting thingsboard and before adding users or changing passwords,
346
+ it needs some time to initialize then you can add users.
347
+
@@ -0,0 +1,325 @@
1
+ # Platform Services
2
+
3
+ It is recommended to install certain third-party software for use
4
+ by digital twins running inside the DTaaS software.
5
+ _These services can only be installed in secure (TLS) mode._
6
+
7
+ The following services can be installed:
8
+
9
+ * **Influx** time-series database and dashboard service
10
+ * **Grafana** visualization and dashboard service
11
+ * **RabbitMQ** AMQP broker and its' management interface
12
+ The **MQTT plugin** of this broker has been enabled.
13
+ So, it can also be used as **MQTT** broker.
14
+ * **MongoDB** database server
15
+ * **ThingsBoard** IoT device management and data visualization platform
16
+ (with PostgreSQL backend)
17
+ * **GitLab** OAuth2 identity provider and Git repository service
18
+
19
+ ## Directory Structure
20
+
21
+ * **config** is used for storing the service configuration
22
+ * **data** is used by the services for storing data
23
+ * **certs** is used for storing the TLS certificates needed by the services.
24
+ * **cli** contains a CLI package for automated service management
25
+
26
+ ## Installation Methods
27
+
28
+ You can install and manage the services using:
29
+
30
+ **CLI Package :** Automated CLI tool for easy service management.
31
+
32
+ ## DTaaS Services CLI
33
+
34
+ A command-line tool for managing DTaaS platform services including MongoDB,
35
+ InfluxDB, RabbitMQ, Grafana, ThingsBoard, and GitLab.
36
+
37
+ ## Features
38
+
39
+ * **Project Initialization:** Generate project structure with config and data directories
40
+ * **Automated Setup:** One command setup of TLS certificates and permissions
41
+ * **Service Management:** Start, stop, and check status of all services
42
+ * **User Management:** Easy creation of user accounts in InfluxDB,
43
+ RabbitMQ, ThingsBoard, and GitLab
44
+ * **Cross platform:** Works on Linux, macOS, and Windows
45
+ * **Configuration-driven:** Reads settings from `config/services.env`
46
+
47
+ ## Installation
48
+
49
+ ### Prerequisites
50
+
51
+ * Python 3.10 or higher
52
+ * Docker and Docker Compose
53
+ * TLS certificates
54
+
55
+ ### Install from Wheel Package
56
+
57
+ Install the standalone wheel package using pip:
58
+
59
+ ```bash
60
+ pip install dtaas_services-0.3.0-py3-none-any.whl
61
+ ```
62
+
63
+ This installs the `dtaas-services` command.
64
+
65
+ To verify the installation:
66
+
67
+ ```bash
68
+ dtaas-services --help
69
+ ```
70
+
71
+ ## Quick Start
72
+
73
+ 1. Navigate to where you want to set up the services and generate the project
74
+ structure and run:
75
+
76
+ ```bash
77
+ dtaas-services generate-project
78
+ ```
79
+
80
+ This creates:
81
+ * `config/` directory with configuration templates
82
+ * `data/` directory for service data
83
+ * `compose.services.yml` for main services
84
+ * `compose.thingsboard.yml` for ThingsBoard and PostgreSQL
85
+
86
+ 2. Update `config/services.env` with your environment values:
87
+ * `HOSTNAME`: Public hostname of the DTaaS server (used for certificate paths)
88
+ * `GITLAB_PORT`: Port for the local GitLab instance (default: `8090`)
89
+ * `GITLAB_ROOT_NEW_PASSWORD`: Strong password to set for the GitLab root admin
90
+ * `TB_SYSADMIN_NEW_PASSWORD`: New password for the ThingsBoard system admin
91
+ * Port numbers for each service
92
+ * `TB_TENANT_NEW_PASSWORD`: New password for the tenant admin
93
+ * `SERVICES_UID`: User ID for service file ownership
94
+ * `SERVICES_GID`: Group ID for service file ownership
95
+
96
+ 3. Update `config/credentials.csv` with user accounts (format: `username,password,email`)
97
+
98
+ **Options:**
99
+
100
+ * `--path` Directory to generate project structure (default: current directory)
101
+
102
+ **Example:**
103
+
104
+ ```bash
105
+ dtaas-services generate-project --path /path/to/project
106
+ ```
107
+
108
+ ## Usage
109
+
110
+ ### Service Setup
111
+
112
+ After generating the project and configuring your settings:
113
+
114
+ ```bash
115
+ dtaas-services setup
116
+ ```
117
+
118
+ This command will:
119
+
120
+ * Copy TLS certificates to the correct locations
121
+ * Set up MongoDB certificates and permissions
122
+ * Set up InfluxDB certificates and permissions
123
+ * Set up RabbitMQ certificates and permissions
124
+ * Set up PostgreSQL and ThingsBoard certificates and permissions
125
+
126
+ Make sure you run the clean command right after
127
+
128
+ ```bash
129
+ dtaas-services clean
130
+ ```
131
+
132
+ ### Managing Services
133
+
134
+ Now you can manage services by simple commands (Start, Stop, Remove and Restart)
135
+
136
+ Example:
137
+
138
+ ```bash
139
+ dtaas-services start
140
+ ```
141
+
142
+ you can specify a services to manage
143
+
144
+ ```bash
145
+ dtaas-services stop -s influxdb
146
+ ```
147
+
148
+ Remove services and their volumes:
149
+
150
+ ```bash
151
+ dtaas-services remove -v
152
+ # Specify
153
+ dtaas-services remove -v -s <service_name>
154
+
155
+ ```
156
+
157
+ ### User Account Management
158
+
159
+ 1. Edit `config/credentials.csv` with user accounts (format: `username,password,email`)
160
+
161
+ 2. Add users to all supported services:
162
+
163
+ ```bash
164
+ dtaas-services user add
165
+ ```
166
+
167
+ This creates user accounts in InfluxDB, RabbitMQ, ThingsBoard, and GitLab
168
+ (each service is skipped gracefully if it is not running).
169
+ For GitLab, a Personal Access Token is created for each new user and
170
+ saved to `config/gitlab_user_tokens.json`.
171
+
172
+ 3. Add users to a specific service:
173
+
174
+ ```bash
175
+ dtaas-services user add -s rabbitmq
176
+ ```
177
+
178
+ ## ThingsBoard
179
+
180
+ It is recommended to install the third-party software ThingsBoard
181
+ for use by digital twins
182
+ running inside the DTaaS software.
183
+ This service can only be installed in secure (TLS) mode.
184
+
185
+ The steps given above install two services:
186
+
187
+ * **ThingsBoard** is an IoT device management and data visualization platform
188
+ * **PostgreSQL** is a database server for ThingsBoard
189
+
190
+ ### ThingsBoard Directory Structure
191
+
192
+ * **config** is used for storing the service configuration
193
+ * **data** is used by the services for storing data
194
+ * **log** is used by the services for logging
195
+ * **certs** is used for storing the TLS certificates needed by the services
196
+ * **script** contains scripts for creating user accounts and service management
197
+
198
+ ### ThingsBoard Installation
199
+
200
+ > **Warning:** Running `dtaas-services install -s thingsboard` more than once
201
+ > will re-run the ThingsBoard schema migration against an already-populated
202
+ > PostgreSQL database, which can corrupt it. If you need to reinstall from
203
+ > scratch, run `dtaas-services clean -s "postgres,thingsboard"` first to wipe
204
+ > all data before re-running the install command.
205
+ > **Note:** It's recommended to specify the service explicitly with `-s <service>`
206
+ > when installing.
207
+ > Make sure that you have runned the clean command before the installation
208
+
209
+ ```bash
210
+ # (It starts PostgreSQL if it's not running, and it checks its health)
211
+ dtaas-services install -s thingsboard
212
+ ```
213
+
214
+ ```bash
215
+ dtaas-services start -s thingsboard
216
+ ```
217
+
218
+ ```bash
219
+
220
+ # After installation, wait some time before adding users
221
+ # This creates the tenant, tenant admin and users.
222
+ dtaas-services user add -s thingsboard
223
+ ```
224
+
225
+ Reset the ThingsBoard sysadmin and tenant admin passwords using values
226
+ configured in `config/services.env`:
227
+
228
+ ```bash
229
+ dtaas-services user reset-password -s thingsboard
230
+ ```
231
+
232
+ This command:
233
+
234
+ * Changes the sysadmin password from the default (`"sysadmin"`) to `TB_SYSADMIN_NEW_PASSWORD`
235
+ * Changes the tenant admin password from the default (`"tenant"`) to
236
+ `TB_TENANT_ADMIN_PASSWORD`
237
+
238
+ ### GitLab Installation
239
+
240
+ **Prerequisites:**
241
+
242
+ * The GitLab container joins the `dtaas-services` Docker network
243
+ (`platform-services`), which is created automatically when the other
244
+ platform services are running. Start them first with
245
+ `dtaas-services start` before installing GitLab.
246
+ * Set `REACT_APP_AUTH_AUTHORITY` in the client config file
247
+ (`deploy/config/client/env.js` for server deployments, or
248
+ `deploy/config/client/env.local.js` for localhost) to
249
+ `https://<hostname>:<GITLAB_PORT>/gitlab`.
250
+
251
+ > **Note:** The DTaaS client uses `react-oidc-context`, which forces
252
+ > redirects to use HTTPS. GitLab must therefore be served over HTTPS
253
+ > at `https://<hostname>:<GITLAB_PORT>/gitlab`
254
+
255
+ To install and configure the local GitLab instance:
256
+
257
+ ```bash
258
+ dtaas-services install -s gitlab
259
+ ```
260
+
261
+ GitLab takes 5–10 minutes to become healthy after the first start.
262
+ The install command checks GitLab’s readiness and returns immediately:
263
+
264
+ * **If GitLab is healthy**: the command runs post-install setup
265
+ (password reset, PAT creation, OAuth app registration) and
266
+ saves the access token to `config/gitlab_tokens.json`.
267
+ * **If GitLab is still starting**: the command prints a status hint
268
+ and exits. Check progress with `dtaas-services status -s gitlab`
269
+ and re-run `dtaas-services install -s gitlab` once the status
270
+ shows "healthy".
271
+
272
+ > **Note:** After a successful setup, `config/gitlab_tokens.json` is backed
273
+ > up to `config/backup_gitlab_tokens.json` and the `root_password` entry is
274
+ > removed from the live tokens file.
275
+ > If the GitLab installation becomes corrupted before the root password is
276
+ > changed, the initial password can be found in the backup file:
277
+ > `config/backup_gitlab_tokens.json`.
278
+ > If that file is also missing, re-install GitLab to generate a new
279
+ > initial password.
280
+ > **Warning:** `config/password.env.current` is managed automatically by
281
+ > the CLI and tracks the current service passwords. Do **not** edit or delete
282
+ > this file manually — doing so may cause password reset commands to fail.
283
+
284
+ To complete the OAuth2 integration with DTaaS and set up GitLab Runner,
285
+ follow the [integration guide](GITLAB_INTEGRATION.md) and
286
+ [runner setup guide](../runner/GITLAB-RUNNER.md).
287
+
288
+ Reset the GitLab root admin password using the value configured in
289
+ `config/services.env` (`GITLAB_ROOT_NEW_PASSWORD`):
290
+
291
+ ```bash
292
+ dtaas-services user reset-password -s gitlab
293
+ ```
294
+
295
+ The command reads the new password from `GITLAB_ROOT_NEW_PASSWORD`
296
+ and applies it via the GitLab API.
297
+
298
+ ## GitLab Post-Install Flow
299
+
300
+ The `dtaas-services install -s gitlab` command performs the following steps
301
+ automatically:
302
+
303
+ 1. Starts the GitLab Docker container
304
+ 2. Checks if GitLab is healthy (non-blocking — exits immediately if not ready)
305
+ 3. Reads the auto-generated root password from the container
306
+ (`/etc/gitlab/initial_root_password`)
307
+ 4. Creates an initial Personal Access Token and saves it to
308
+ `config/gitlab_tokens.json`
309
+ 5. Creates Server and Client OAuth application tokens.
310
+
311
+ ## Troubleshooting
312
+
313
+ ### Permission Issues (Linux/macOS)
314
+
315
+ If you encounter permission errors when setting up services,
316
+ ensure you run the setup command with appropriate privileges:
317
+
318
+ ```bash
319
+ sudo -E env PATH="$PATH" dtaas-services setup
320
+ ```
321
+
322
+ ### Thingsboard connection error
323
+
324
+ After starting thingsboard and before adding users or changing passwords,
325
+ it needs some time to initialize then you can add users.
File without changes
@@ -0,0 +1,37 @@
1
+ """DTaaS Services CLI main entry point."""
2
+
3
+ import click
4
+ from .commands import service_ops, setup_ops, user_ops
5
+
6
+
7
+ @click.group()
8
+ def services():
9
+ """Manage DTaaS platform services."""
10
+
11
+
12
+ # Register setup and installation commands
13
+ services.add_command(setup_ops.generate_project, name="generate-project")
14
+ services.add_command(setup_ops.setup)
15
+ services.add_command(setup_ops.install)
16
+
17
+ # Register service operational commands
18
+ services.add_command(service_ops.start)
19
+ services.add_command(service_ops.stop)
20
+ services.add_command(service_ops.restart)
21
+ services.add_command(service_ops.status)
22
+ services.add_command(service_ops.remove)
23
+ services.add_command(service_ops.clean)
24
+
25
+
26
+ # Register user management command group
27
+ @services.group()
28
+ def user():
29
+ """User account management for services."""
30
+
31
+
32
+ user.add_command(user_ops.add)
33
+ user.add_command(user_ops.reset_password)
34
+
35
+
36
+ if __name__ == "__main__":
37
+ services()
@@ -0,0 +1 @@
1
+ """DTaaS Services CLI command modules."""