Make amphora timezone configurable

The new amp_timezone option allows to adjust the timezone of
amphora using cloud-init.

Change-Id: I2f49cbb7f8d99ba2da878bbfc7081a3cc3b3aa07
This commit is contained in:
Tom Weininger 2022-04-29 14:18:40 +02:00
parent 2376f68bba
commit 829e44acbd
7 changed files with 22 additions and 4 deletions

View File

@ -332,6 +332,7 @@ function octavia_configure {
iniset $OCTAVIA_CONF controller_worker network_driver ${OCTAVIA_NETWORK_DRIVER}
iniset $OCTAVIA_CONF controller_worker image_driver ${OCTAVIA_IMAGE_DRIVER}
iniset $OCTAVIA_CONF controller_worker amp_image_tag ${OCTAVIA_AMP_IMAGE_TAG}
iniset $OCTAVIA_CONF controller_worker amp_timezone $(readlink -e /etc/localtime | sed "s/\/usr\/share\/zoneinfo\///")
iniuncomment $OCTAVIA_CONF health_manager heartbeat_key
iniset $OCTAVIA_CONF health_manager heartbeat_key ${OCTAVIA_HEALTH_KEY}

View File

@ -311,6 +311,9 @@
# Upload the ssh key as the service_auth user described elsewhere in this config.
# Leaving this variable blank will install no ssh key on the amphora.
# amp_ssh_key_name =
# Defines the timezone to use as represented in /usr/share/zoneinfo.
# Default is UTC.
# amp_timezone =
# Networks to attach to the Amphorae examples:
# - One primary network

View File

@ -477,6 +477,10 @@ controller_worker_opts = [
default='',
help=_('Optional SSH keypair name, in nova, that will be used '
'for the authorized_keys inside the amphora.')),
cfg.StrOpt('amp_timezone',
default='UTC',
help=_('The timezone to use in the Amphora as represented in '
'/usr/share/zoneinfo.')),
cfg.ListOpt('amp_boot_network_list',
default='',
help=_('List of networks to attach to the Amphorae. '

View File

@ -37,3 +37,5 @@ runcmd:
{% if user_data -%}
- service amphora-agent restart
{%- endif %}
timezone: {{ timezone }}

View File

@ -35,4 +35,5 @@ class UserDataJinjaCfg(object):
constants.USER_DATA_CONFIG_DRIVE_TEMPLATE)
def build_user_data_config(self, user_data):
return self.agent_template.render(user_data=user_data)
return self.agent_template.render(
user_data=user_data, timezone=CONF.controller_worker.amp_timezone)

View File

@ -40,7 +40,8 @@ BASE_CFG = ('#cloud-config\n'
WRITE_FILES_CFG = ('write_files:\n')
RUN_CMD = ('runcmd:\n'
'- systemctl restart rsyslog\n')
WRITE_FILES_CMD = ('- service amphora-agent restart')
WRITE_FILES_CMD = ('- service amphora-agent restart\n')
TIMEZONE = '\ntimezone: UTC'
class TestUserDataJinjaCfg(base.TestCase):
@ -52,12 +53,12 @@ class TestUserDataJinjaCfg(base.TestCase):
expected_config = (BASE_CFG + WRITE_FILES_CFG +
'- path: /test/config/path\n'
' content: |\n' + EXPECTED_TEST_CONFIG +
RUN_CMD + WRITE_FILES_CMD)
RUN_CMD + WRITE_FILES_CMD + TIMEZONE)
ud_cfg = udc.build_user_data_config({'/test/config/path': TEST_CONFIG})
self.assertEqual(expected_config, ud_cfg)
def test_build_user_data_config_no_files(self):
udc = user_data_jinja_cfg.UserDataJinjaCfg()
expected_config = (BASE_CFG + '\n' + RUN_CMD)
expected_config = (BASE_CFG + '\n' + RUN_CMD + '\n' + TIMEZONE)
ud_cfg = udc.build_user_data_config({})
self.assertEqual(expected_config, ud_cfg)

View File

@ -0,0 +1,6 @@
---
features:
- |
Configuration of the amphora's timezone is now possible using new
configuration setting "amp_timezone" in the controller_worker options
group.