Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up jinja2 conditionals in config template #385

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions controllers/glance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ func (r *GlanceReconciler) generateServiceConfig(
// We only need a minimal 00-config.conf that is only used by db-sync job,
// hence only passing the database related parameters
templateParameters := map[string]interface{}{
"MinimalConfig": true, // This tells the template to generate a minimal config
"DatabaseConnection": fmt.Sprintf("mysql+pymysql://%s:%s@%s/%s",
instance.Spec.DatabaseUser,
string(ospSecret.Data[instance.Spec.PasswordSelectors.Database]),
Expand Down
61 changes: 25 additions & 36 deletions templates/glance/config/00-config.conf
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
{{ if (index . "MinimalConfig") -}}
[DEFAULT]
verbose=True
{{ if (index . "CacheEnabled") -}}
image_cache_dir = {{ .ImageCacheDir }}
image_cache_max_size = {{ .CacheMaxSize }}
image_cache_stall_time = 86400
{{ end -}}

[database]
connection = {{ .DatabaseConnection }}
{{ else -}}
[DEFAULT]
verbose=True
{{ if (index . "ShowImageDirectUrl") }}
show_image_direct_url={{ .ShowImageDirectUrl }}
{{ end }}
{{ if (index . "ShowMultipleLocations") }}
show_multiple_locations={{ .ShowMultipleLocations }}
{{ end }}
node_staging_uri=file:///var/lib/glance/staging
enabled_import_methods=[web-download]
bind_host=127.0.0.1
bind_port=9293
workers=3
{{ if (index . "LogFile") }}
# enable log rotation in oslo config by default
max_logfile_count=5
max_logfile_size_mb=50
log_rotation_type=size
log_file = {{ .LogFile }}
{{ end }}
enabled_backends=default_backend:file
# cache related parameters
{{ if (index . "CacheEnabled") }}
{{ if (index . "CacheEnabled") -}}
image_cache_dir = {{ .ImageCacheDir }}
image_cache_max_size = {{ .CacheMaxSize }}
image_cache_stall_time = 86400
{{ end }}
{{ end -}}

{{ if (index . "QuotaEnabled") }}
use_keystone_limits = {{ .QuotaEnabled }}

[oslo_limit]
password = {{ .ServicePassword }}
{{ end }}

[database]
{{ if (index . "DatabaseConnection") }}
connection = {{ .DatabaseConnection }}
{{ end }}
max_retries = -1
db_max_retries = -1

Expand All @@ -47,27 +48,17 @@ filesystem_store_datadir = /var/lib/glance/images
default_backend=default_backend

[keystone_authtoken]
{{ if (index . "KeystonePublicURL") }}
www_authenticate_uri={{ .KeystonePublicURL }}
{{ end }}
{{ if (index . "KeystoneInternalURL") }}
auth_url={{ .KeystoneInternalURL }}
{{ end }}
auth_type=password
{{ if (index . "ServiceUser") }}
username={{ .ServiceUser }}
{{ end }}
{{ if (index . "ServicePassword") }}
password = {{ .ServicePassword }}
{{ end }}
project_domain_name=Default
user_domain_name=Default
project_name=service

{{ if (index . "ServicePassword") }}
[service_user]
password = {{ .ServicePassword }}
{{ end }}

[oslo_messaging_notifications]
# TODO: update later once rabbit is working
Expand All @@ -78,11 +69,11 @@ driver=noop
enable_proxy_headers_parsing=True

[paste_deploy]
{{ if (index . "CacheEnabled") }}
{{ if (index . "CacheEnabled") -}}
flavor = keystone+cachemanagement
{{ else }}
{{ else -}}
flavor = keystone
{{ end }}
{{ end -}}

[os_glance_staging_store]
filesystem_store_datadir = /var/lib/glance/os_glance_staging_store/
Expand All @@ -91,23 +82,19 @@ filesystem_store_datadir = /var/lib/glance/os_glance_staging_store/
filesystem_store_datadir = /var/lib/glance/os_glance_tasks_store/

[oslo_limit]
{{ if (index . "KeystoneInternalURL") }}
auth_url={{ .KeystoneInternalURL }}
{{ end }}
auth_type = password
{{ if (index . "ServiceUser") }}
username={{ .ServiceUser }}
{{ end }}
system_scope = all
{{ if (index . "DomainID") }}
{{ if (index . "DomainID") -}}
user_domain_id = {{ .DomainID }}
{{ end }}
{{ if (index . "EndpointID") }}
{{ end -}}
{{ if (index . "EndpointID") -}}
endpoint_id = {{ .EndpointID }}
{{ end }}
{{ if (index . "Region") }}
{{ end -}}
{{ if (index . "Region") -}}
region_name = {{ .Region }}
{{ end }}
{{ end -}}

[image_import_opts]
image_import_plugins = ['no_op']
Expand All @@ -118,3 +105,5 @@ lock_path = /var/locks/openstack/os-brick
[oslo_policy]
enforce_new_defaults = true
enforce_scope = true
{{/* not "MinimalConfig" */ -}}
{{ end -}}