Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
smartpublicbuilding
openhab-pb-stack
Commits
aea6cb49
Commit
aea6cb49
authored
Jan 28, 2019
by
Dobli
Browse files
added lables for subdomains
parent
877c42f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
building_manager.py
View file @
aea6cb49
...
...
@@ -149,6 +149,8 @@ def add_nodered_service(base_dir, hostname):
template
[
'deploy'
][
'labels'
].
append
(
f
'backup=
{
hostname
}
'
)
template
[
'deploy'
][
'labels'
].
extend
(
generate_traefik_path_labels
(
service_name
,
segment
=
'main'
))
template
[
'deploy'
][
'labels'
].
extend
(
generate_traefik_subdomain_labels
(
service_name
,
segment
=
'sub'
))
add_or_update_compose_service
(
compose_path
,
service_name
,
template
)
...
...
@@ -209,6 +211,25 @@ def generate_traefik_host_labels(hostname, segment=None, priority=1):
return
label_list
def
generate_traefik_subdomain_labels
(
subdomain
,
segment
=
None
,
priority
=
2
):
"""Generates a traefik subdomain with necessary redirects
:subdomain: subdomain that will be assigned to a service
:segment: Optional traefik segment when using multiple rules
:priority: Priority of frontend rule
:returns: list of labels for traefik
"""
label_list
=
[]
# check segment
segment
=
f
'.
{
segment
}
'
if
segment
is
not
None
else
''
# fill list
label_list
.
append
(
f
'traefik
{
segment
}
.frontend.rule='
f
'HostRegexp:
{
subdomain
}
.{{domain:[a-zA-z0-9-]+}}'
)
label_list
.
append
(
f
'traefik
{
segment
}
.frontend.priority=
{
priority
}
'
)
return
label_list
def
generate_traefik_path_labels
(
url_path
,
segment
=
None
,
priority
=
2
):
"""Generates a traefik path url with necessary redirects
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment