Merge ~pguimaraes/ntp-charm/+git/ntp-charm:master into ntp-charm:master

Proposed by Pedro GuimarĂ£es
Status: Superseded
Proposed branch: ~pguimaraes/ntp-charm/+git/ntp-charm:master
Merge into: ntp-charm:master
Diff against target: 63 lines (+23/-2)
2 files modified
config.yaml (+9/-0)
lib/ntp_implementation.py (+14/-2)
Reviewer Review Type Date Requested Status
Joel Sing (community) Needs Fixing
Review via email: mp+363665@code.launchpad.net

This proposal has been superseded by a proposal from 2019-04-05.

Commit message

Added manual override on NTP package selection.
LP: #1817516

Description of the change

Added manual override on NTP package selection.
LP: #1817516

To post a comment you must log in.
Revision history for this message
đŸ¤– Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Joel Sing (jsing) :
review: Needs Fixing
6e39713... by Nicolas Pochet

Code cleanup

da73241... by Pedro GuimarĂ£es

Merged changes from commit allow-ntp-choice

Unmerged commits

da73241... by Pedro GuimarĂ£es

Merged changes from commit allow-ntp-choice

6e39713... by Nicolas Pochet

Code cleanup

8f68125... by Przemyslaw Hausman

Fix testing the value of ntp_package config option

c94981b... by Przemyslaw Hausman

Fix yaml parsing error due to the \t character used

65a8104... by Pedro GuimarĂ£es

Added manual override on NTP package selection.
LP: #1817516

2fe6f6c... by Przemyslaw Hausman

Fix testing the value of ntp_package config option

62be0f8... by Przemyslaw Hausman

Fix yaml parsing error due to the \t character used

6256555... by Pedro GuimarĂ£es

Added manual override on NTP package selection.
LP: #1817516

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/config.yaml b/config.yaml
2index f9c541f..f7574a6 100644
3--- a/config.yaml
4+++ b/config.yaml
5@@ -62,3 +62,12 @@ options:
6 description: >
7 Use iburst for all peers/sources, not just those received via the
8 master relation.
9+ ntp_package:
10+ default: ""
11+ type: string
12+ description: >
13+ If set to "ntp" the ntp package will be installed and configured, or if set to
14+ "chrony" the chrony package will be installed and configured. If unspecified
15+ the appropriate package will be selected based on the operating system.
16+ Please note that the use of ntp on Ubuntu bionic or later is not recommended as it
17+ does not receive security updates.
18diff --git a/lib/ntp_implementation.py b/lib/ntp_implementation.py
19index 3e20ccb..f7b93fd 100644
20--- a/lib/ntp_implementation.py
21+++ b/lib/ntp_implementation.py
22@@ -5,8 +5,12 @@
23
24 """NTP implementation details"""
25
26+from charmhelpers.core.hookenv import (
27+ config as config_get,
28+)
29 import charmhelpers.contrib.templating.jinja as templating
30 import charmhelpers.core.host
31+import charmhelpers.core.hookenv
32 import charmhelpers.osplatform
33 import os.path
34 import shutil
35@@ -54,11 +58,13 @@ class NTPImplementation:
36
37 def set_config(self, config):
38 with open(self.config_file(), "w") as conffile:
39- conffile.write(templating.render(self._config_file_template(), config))
40+ conffile.write(templating.render(
41+ self._config_file_template(), config))
42
43 def set_startup_options(self, config):
44 with open(self._startup_config_file(), "w") as startup:
45- startup.write(templating.render(self._startup_template_file(), config))
46+ startup.write(templating.render(
47+ self._startup_template_file(), config))
48
49 def _startup_config_file(self):
50 raise NotImplementedError
51@@ -137,6 +143,12 @@ def get_implementation(implementation_name=None):
52 platform = charmhelpers.osplatform.get_platform()
53 version = float(charmhelpers.core.host.lsb_release()['DISTRIB_RELEASE'])
54
55+ ntp_package = charmhelpers.core.hookenv.config('ntp_package')
56+ if ntp_package == "ntp":
57+ return NTPd()
58+ elif ntp_package == "chrony":
59+ return Chronyd()
60+
61 if platform == 'ubuntu':
62 if version > 18:
63 # Ubuntu 18.04 or later: use chronyd

Subscribers

People subscribed via source and target branches