Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IoT Capstone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cooper Little
IoT Capstone
Commits
d517f333
Commit
d517f333
authored
1 year ago
by
TH
Browse files
Options
Downloads
Patches
Plain Diff
Config file generator updated to support new single config file to rule them all.
parent
e48906e9
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
config_generator.py
+131
-1
131 additions, 1 deletion
config_generator.py
with
131 additions
and
1 deletion
config_generator.py
+
131
−
1
View file @
d517f333
import
os.path
import
os
import
copy
import
json
def
write_default_file
(
fname
,
description
,
content
,
existing_inputs
=
None
,
**
inputs
):
...
...
@@ -24,6 +27,132 @@ def write_default_file(fname, description, content, existing_inputs=None, **inpu
return
inputs
def
ask_overwrite
(
fname
,
content
):
overwrite
=
True
if
os
.
path
.
exists
(
fname
):
overwrite
=
input
(
f
'
Overwrite remote_config.json (y/n)?
'
)
==
'
y
'
if
overwrite
:
print
(
f
'
Overwriting
{
fname
}
...
'
)
print
(
json
.
dumps
(
content
,
indent
=
2
))
with
open
(
fname
,
'
w
'
)
as
f
:
f
.
write
(
json
.
dumps
(
content
,
indent
=
2
))
print
(
'
Done.
'
)
else
:
print
(
f
'
Did not change
{
fname
}
.
'
)
org
=
input
(
'
InfluxDB Organisation?
'
)
bucket
=
input
(
'
InfluxDB Bucket?
'
)
token
=
input
(
'
InfluxDB Token?
'
)
measurement
=
input
(
'
InfluxDB Measurement?
'
)
print
(
'
Remote URL example: https://influxdb.yourdomain.name
'
)
remote_url
=
input
(
'
Remote InfluxDB URL?
'
)
remote_influx_instances
=
{
"
local
"
:
{
"
enabled
"
:
True
,
"
bucket
"
:
bucket
,
"
org
"
:
org
,
"
token
"
:
token
,
"
url
"
:
remote_url
,
# https://influxdb.yourdomain.name, for example
"
measurement
"
:
measurement
}
}
print
(
'
Remote control URL example: https://control.yourdomain.name
'
)
remote_control_url
=
input
(
'
Remote control URL?
'
)
print
(
'
Remote image URL example: https://images.yourdomain.name
'
)
remote_images_url
=
input
(
'
Remote images URL?
'
)
remote_config
=
{
"
influxdb_instances
"
:
remote_influx_instances
,
"
amigos_control
"
:
remote_control_url
,
"
amigos_images
"
:
remote_images_url
}
ask_overwrite
(
'
remote_config.json
'
,
remote_config
)
print
(
'
Local URL example: http://192.168.0.219:8086
'
)
print
(
'
Note: This should use the server static IP on the local network that the Raspberry Pis connect to.
'
)
local_url
=
input
(
'
Local InfluxDB URL?
'
)
print
(
'
Local control URL example: http://192.168.0.219:10000
'
)
control_url
=
input
(
'
Local control URL?
'
)
print
(
'
Local image URL example: http://192.168.0.219:10001
'
)
images_url
=
input
(
'
Local images URL?
'
)
influx_instances
=
copy
.
deepcopy
(
remote_influx_instances
)
influx_instances
[
'
local
'
][
'
url
'
]
=
local_url
#images_url = input('Local images URL? ')
print
(
'
Local Grafana URL example: http://localhost:3000
'
)
print
(
'
Note: This is used for the management back end to update Grafana.
'
)
local_grafana_url
=
input
(
'
Local Grafana URL?
'
)
grafana_api_key
=
input
(
'
Grafana API key?
'
)
print
(
'
Example port: 8000
'
)
fastapi_port
=
int
(
input
(
'
FastAPI internal port?
'
))
print
(
'
Example port: 10000
'
)
control_port
=
int
(
input
(
'
Control port?
'
))
print
(
'
Example port: 10001
'
)
images_port
=
int
(
input
(
'
Images port?
'
))
print
(
'
Example Grafana display URL: https://grafana.yourdomain.name
'
)
print
(
'
Note: This is used for making clickable links in the management interface.
'
)
grafana_display_url
=
input
(
'
Grafana display URL?
'
)
print
(
'
Example dashboard camera URL: https://camera.yourdomain.name
'
)
print
(
'
Note: This is used for embedding camera streams into the dashboards.
'
)
camera_url
=
input
(
'
Dashboard camera URL?
'
)
# print('Example port: 8001')
# camera_port = int(input('Camera port? ')) # TODO: Add this to config, so image_streaming_wrangler can use it...
# TODO:
# manage_port = int(input('Management interface port? '))
# TODO:
# redirector_port = int(input('Main URL redirector port? '))
default_config
=
{
"
influxdb_instances
"
:
influx_instances
,
"
amigos_control
"
:
control_url
,
"
amigos_images
"
:
images_url
,
"
grafana
"
:
local_grafana_url
,
"
grafana_api_key
"
:
grafana_api_key
,
"
fastapi_internal_port
"
:
fastapi_port
,
"
amigos_control_port
"
:
control_port
,
"
amigos_images_port
"
:
images_port
,
"
grafana_display_url
"
:
grafana_display_url
,
"
dash_camera_url
"
:
camera_url
,
"
general_dashboards
"
:
{
"
Test_Homepage
"
:
{
"
name
"
:
"
Test_Homepage
"
,
"
folder
"
:
"
Homepage
"
,
"
type
"
:
"
printer_info
"
,
"
config
"
:
{
"
list_tag
"
:
"
machine
"
,
"
list_folder
"
:
"
Machine Info
"
}
},
},
"
default_machine_folder
"
:
"
Machine Info
"
,
"
machine_folders
"
:
{
#"Sim Makerbot Printer": "Overridden Simulated Printers"
},
"
email
"
:
{
}
}
ask_overwrite
(
'
config.json
'
,
default_config
)
write_default_file
(
'
email.ini
'
,
'
This allows emailing of pdf reports and alerts.
'
,
...
...
@@ -39,6 +168,7 @@ password='Enter email password: ',
smtp
=
'
Enter SMTP server hostname:
'
)
"""
write_default_file(
'
grafanaconfig.ini
'
,
'
This allows dashboard generation automatically for new printers.
'
,
...
...
@@ -130,4 +260,4 @@ enable = True
'''
,
existing_inputs=inputs
)
"""
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment