diff --git a/releasenotes/notes/undercloud-timezone-052a6c1c05e80850.yaml b/releasenotes/notes/undercloud-timezone-052a6c1c05e80850.yaml new file mode 100644 index 000000000..12d41a2f3 --- /dev/null +++ b/releasenotes/notes/undercloud-timezone-052a6c1c05e80850.yaml @@ -0,0 +1,12 @@ +--- +features: + - | + Host timezone can be managed during the undercloud installation. The default + timezone is the timezone already configured for the system. The timezone + can be configured by setting undercloud_timezone in undercloud.conf +upgrade: + - | + Host timezone can be managed during the undercloud upgrade. The default + timezone is the timezone already configured for the system. The timezone + can be configured by setting undercloud_timezone in undercloud.conf and it + is recommended to set this going forward. diff --git a/tripleoclient/config/undercloud.py b/tripleoclient/config/undercloud.py index 87c6d2df4..efefdb8a0 100644 --- a/tripleoclient/config/undercloud.py +++ b/tripleoclient/config/undercloud.py @@ -130,6 +130,10 @@ class UndercloudConfig(StandaloneConfig): default=['0.pool.ntp.org', '1.pool.ntp.org', '2.pool.ntp.org', '3.pool.ntp.org'], help=_('List of ntp servers to use.')), + cfg.StrOpt('undercloud_timezone', default=None, + help=_('Host timezone to be used. If no timezone is ' + 'specified, the existing timezone configuration ' + 'is used.')), cfg.StrOpt('overcloud_domain_name', default='localdomain', help=_( diff --git a/tripleoclient/tests/config/test_config_undercloud.py b/tripleoclient/tests/config/test_config_undercloud.py index 657ce01d5..cf293ad33 100644 --- a/tripleoclient/tests/config/test_config_undercloud.py +++ b/tripleoclient/tests/config/test_config_undercloud.py @@ -71,6 +71,7 @@ class TestUndercloudConfig(base.TestCase): 'undercloud_ntp_servers', 'undercloud_public_host', 'undercloud_service_certificate', + 'undercloud_timezone', 'undercloud_update_packages', 'upgrade_cleanup'] self.assertEqual(expected, [x.name for x in ret]) @@ -133,6 +134,7 @@ class TestUndercloudConfig(base.TestCase): 'undercloud_ntp_servers', 'undercloud_public_host', 'undercloud_service_certificate', + 'undercloud_timezone', 'undercloud_update_packages', 'upgrade_cleanup'] self.assertEqual(expected, [x.name for x in ret]) diff --git a/tripleoclient/v1/undercloud_config.py b/tripleoclient/v1/undercloud_config.py index 93a2cb04d..559f87063 100644 --- a/tripleoclient/v1/undercloud_config.py +++ b/tripleoclient/v1/undercloud_config.py @@ -32,6 +32,7 @@ from jinja2 import meta from osc_lib.i18n import _ from oslo_config import cfg +from time import strftime from tripleo_common.image import kolla_builder from tripleoclient.config.undercloud import load_global_config @@ -383,6 +384,11 @@ def prepare_undercloud_deploy(upgrade=False, no_validations=False, if CONF.get('undercloud_ntp_servers', None): env_data['NtpServer'] = CONF['undercloud_ntp_servers'] + if CONF.get('undercloud_timezone', None): + env_data['TimeZone'] = CONF['undercloud_timezone'] + else: + env_data['TimeZone'] = strftime("%Z") + if CONF.get('enable_validations', False): env_data['UndercloudConfigFilePath'] = constants.UNDERCLOUD_CONF_PATH if not no_validations: