Skip to content

Commit 30c78a7

Browse files
authored
Saimon/improve ntp config (#137)
* Add ntp commands, fix docs and log print
1 parent ee695a6 commit 30c78a7

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

cterasdk/core/cloudfs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def mkfg(self, name, user=None):
6262
logging.getLogger().info('Folder group created. %s', {'name': name, 'owner': param.owner})
6363
return response
6464
except CTERAException as error:
65-
logging.getLogger().error('Folder group creation failed. %s', {'name': name, 'owner': user})
65+
logging.getLogger().error('Folder group creation failed. %s', {'name': name, 'owner': str(user)})
6666
raise error
6767

6868
def rmfg(self, name):

cterasdk/edge/ntp.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,30 @@
77
class NTP(BaseCommand):
88
""" Gateway NTP configuration """
99

10+
def get_configuration(self):
11+
return self._gateway.get('/config/time')
12+
13+
@property
14+
def servers(self):
15+
return self._gateway.get('/config/time/NTPServer')
16+
1017
def enable(self, servers=None):
1118
"""
1219
Enable NTP
1320
1421
:param list[str] servers: List of NTP servers address
1522
"""
1623
logging.getLogger().info("Enabling time synchronization with ntp servers.")
17-
1824
self._gateway.put('/config/time/NTPMode', Mode.Enabled)
19-
2025
logging.getLogger().info("Time synchronization enabled.")
2126

2227
if servers:
2328
logging.getLogger().info("Updating time servers. %s", {'servers': servers})
24-
2529
self._gateway.put('/config/time/NTPServer', servers)
26-
2730
logging.getLogger().info("Time servers updated. %s", {'servers': servers})
2831

2932
def disable(self):
3033
""" Disable NTP """
3134
logging.getLogger().info("Disabling time synchronization with ntp servers.")
32-
3335
self._gateway.put('/config/time/NTPMode', Mode.Disabled)
34-
3536
logging.getLogger().info("Time synchronization disabled.")

docs/source/user_guides/Gateway/Gateway.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ SSL
10801080
.. automethod:: cterasdk.edge.ssl.SSL.remove_storage_ca
10811081
:noindex:
10821082

1083-
.. automethod:: cterasdk.edge.ssl.SSL.set_certificate
1083+
.. automethod:: cterasdk.edge.ssl.SSL.import_certificate
10841084
:noindex:
10851085

10861086
.. code-block:: python
@@ -1096,7 +1096,7 @@ SSL
10961096
Specify certificates in the following order: domain cert, intermediary certs, CA cert
10971097
You may include as many intermediate certificates as needed
10981098
"""
1099-
filer.ssl.set_certificate(private_key, certificate, intermediate_cert, ca_certificate)
1099+
filer.ssl.import_certificate(private_key, certificate, intermediate_cert, ca_certificate)
11001100
11011101
.. danger: Exercise caution. Test thoroughly prior to implementing in production. Ensure the integrity of the PEM encoded private key and certificates. Supplying an invalid private key or certificate will disable administrative access to the filer and would require CTERA Support to re-enable it.
11021102

tests/ut/test_edge_ntp.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77

88
class TestEdgeNTP(base_edge.BaseEdgeTest):
99

10+
def test_get_configuration(self):
11+
get_response = 'Success'
12+
self._init_filer(get_response=get_response)
13+
ret = ntp.NTP(self._filer).get_configuration()
14+
self._filer.get.assert_called_once_with('/config/time')
15+
self.assertEqual(ret, get_response)
16+
1017
def test_enable_ntp(self):
1118
self._init_filer()
1219
ntp.NTP(self._filer).enable()

0 commit comments

Comments
 (0)